Skip to content

Commit 1072608

Browse files
committed
Documented what the regular expression /\/\-[\w\-]+\.hbs/ does
1 parent d9f847f commit 1072608

File tree

5 files changed

+35
-8
lines changed

5 files changed

+35
-8
lines changed

lib/migrator.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,15 @@ module.exports = class Migrator {
7575
// Extract '/app/templates/components/nested1/nested-component.hbs'
7676
let filePathFromApp = templateFilePath.slice(this.projectRoot.length);
7777

78+
/*
79+
When Ember sees `{{partial "foo"}}`, it will look for the template in
80+
two locations:
81+
82+
- `app/templates/foo.hbs`
83+
- `app/templates/-foo.hbs`
84+
85+
If `filePathFromApp` matches the latter pattern, we remove the hyphen.
86+
*/
7887
if (/\/\-[\w\-]+\.hbs/.test(filePathFromApp)) {
7988
filePathFromApp = filePathFromApp.replace('/-', '/');
8089
}

test/fixtures/classic-to-flat/example-1/input.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,15 @@ module.exports = {
6666

6767
// A partial template
6868
'partials': {
69-
'partials-template.hbs': '{{!-- partials-template.hbs --}}',
69+
'partial-one-template.hbs': '{{!-- partial-one-template.hbs --}}',
70+
'partial-two-template.hbs': '{{!-- partial-two-template.hbs --}}',
71+
'-partial-three-template.hbs': '{{!-- partial-three-template.hbs --}}',
72+
7073
'with-partial.hbs': [
7174
'{{!-- with-partial.hbs --}}',
72-
'{{partial "components/partials/partials-template"}}'
75+
'{{partial "components/partials/partial-one-template"}}',
76+
'{{partial "components/partials/partial-two-template"}}',
77+
'{{partial "components/partials/partial-three-template"}}'
7378
].join('\n')
7479
}
7580
}

test/fixtures/classic-to-flat/example-1/output.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,9 @@ module.exports = {
4444
'partials': {
4545
'with-partial.hbs': [
4646
'{{!-- with-partial.hbs --}}',
47-
'{{partial "components/partials/partials-template"}}'
47+
'{{partial "components/partials/partial-one-template"}}',
48+
'{{partial "components/partials/partial-two-template"}}',
49+
'{{partial "components/partials/partial-three-template"}}'
4850
].join('\n')
4951
}
5052
},
@@ -60,7 +62,9 @@ module.exports = {
6062

6163
// A partial template
6264
'partials': {
63-
'partials-template.hbs': '{{!-- partials-template.hbs --}}',
65+
'partial-one-template.hbs': '{{!-- partial-one-template.hbs --}}',
66+
'partial-two-template.hbs': '{{!-- partial-two-template.hbs --}}',
67+
'-partial-three-template.hbs': '{{!-- partial-three-template.hbs --}}'
6468
}
6569
}
6670
}

test/fixtures/classic-to-nested/example-1/input.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,15 @@ module.exports = {
6666

6767
// A partial template
6868
'partials': {
69-
'partials-template.hbs': '{{!-- partials-template.hbs --}}',
69+
'partial-one-template.hbs': '{{!-- partial-one-template.hbs --}}',
70+
'partial-two-template.hbs': '{{!-- partial-two-template.hbs --}}',
71+
'-partial-three-template.hbs': '{{!-- partial-three-template.hbs --}}',
72+
7073
'with-partial.hbs': [
7174
'{{!-- with-partial.hbs --}}',
72-
'{{partial "components/partials/partials-template"}}'
75+
'{{partial "components/partials/partial-one-template"}}',
76+
'{{partial "components/partials/partial-two-template"}}',
77+
'{{partial "components/partials/partial-three-template"}}'
7378
].join('\n')
7479
}
7580
}

test/fixtures/classic-to-nested/example-1/output.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,9 @@ module.exports = {
5555
'with-partial': {
5656
'index.hbs': [
5757
'{{!-- with-partial.hbs --}}',
58-
'{{partial "components/partials/partials-template"}}'
58+
'{{partial "components/partials/partial-one-template"}}',
59+
'{{partial "components/partials/partial-two-template"}}',
60+
'{{partial "components/partials/partial-three-template"}}'
5961
].join('\n')
6062
}
6163
}
@@ -72,7 +74,9 @@ module.exports = {
7274

7375
// A partial template
7476
'partials': {
75-
'partials-template.hbs': '{{!-- partials-template.hbs --}}',
77+
'partial-one-template.hbs': '{{!-- partial-one-template.hbs --}}',
78+
'partial-two-template.hbs': '{{!-- partial-two-template.hbs --}}',
79+
'-partial-three-template.hbs': '{{!-- partial-three-template.hbs --}}'
7680
}
7781
}
7882
}

0 commit comments

Comments
 (0)