File tree 4 files changed +54
-0
lines changed
changelog_unreleased/handlebars
tests/format/handlebars/basics
4 files changed +54
-0
lines changed Original file line number Diff line number Diff line change
1
+ #### Support Glimmer's named blocks (#11899 by @duailibe )
2
+
3
+ Prettier already supported this feature, but it converted empty named blocks to self-closing, which is not supported by the Glimmer compiler.
4
+
5
+ See: [ Glimmer's named blocks] ( https://emberjs.github.io/rfcs/0460-yieldable-named-blocks.html ) .
6
+
7
+ <!-- prettier-ignore -->
8
+ ``` hbs
9
+ // Input
10
+ <Component>
11
+ <:named></:named>
12
+ </Component>
13
+
14
+ // Prettier stable
15
+ <Component>
16
+ <:named />
17
+ </Component>
18
+
19
+ // Prettier main
20
+ <Component>
21
+ <:named></:named>
22
+ </Component>
23
+ ```
Original file line number Diff line number Diff line change @@ -32,6 +32,7 @@ function isGlimmerComponent(node) {
32
32
return (
33
33
isNodeOfSomeType ( node , [ "ElementNode" ] ) &&
34
34
typeof node . tag === "string" &&
35
+ node . tag [ 0 ] !== ":" &&
35
36
( isUppercase ( node . tag [ 0 ] ) || node . tag . includes ( "." ) )
36
37
) ;
37
38
}
Original file line number Diff line number Diff line change @@ -93,6 +93,30 @@ printWidth: 80
93
93
================================================================================
94
94
` ;
95
95
96
+ exports [` named-block.hbs format 1` ] = `
97
+ ====================================options=====================================
98
+ parsers: ["glimmer"]
99
+ printWidth: 80
100
+ | printWidth
101
+ =====================================input======================================
102
+ <ComponentWithNamedBlocks >
103
+ <:first-named-block></:first-named-block>
104
+ <:second-named-block> </:second-named-block>
105
+ <:named-block-with-comment>{ {! Do not convert to an empty element }} </:named-block-with-comment>
106
+ <:named-block-with-content>Hello</:named-block-with-content>
107
+ </ComponentWithNamedBlocks >
108
+
109
+ =====================================output=====================================
110
+ <ComponentWithNamedBlocks >
111
+ <:first-named-block></:first-named-block>
112
+ <:second-named-block> </:second-named-block>
113
+ <:named-block-with-comment
114
+ >{ {! Do not convert to an empty element }} </:named-block-with-comment>
115
+ <:named-block-with-content>Hello</:named-block-with-content>
116
+ </ComponentWithNamedBlocks >
117
+ ================================================================================
118
+ ` ;
119
+
96
120
exports [` nested-path.hbs format 1` ] = `
97
121
====================================options=====================================
98
122
parsers: ["glimmer"]
Original file line number Diff line number Diff line change
1
+ <ComponentWithNamedBlocks >
2
+ <:first-named-block ></:first-named-block >
3
+ <:second-named-block > </:second-named-block >
4
+ <:named-block-with-comment >{{! Do not convert to an empty element}} </:named-block-with-comment >
5
+ <:named-block-with-content >Hello</:named-block-with-content >
6
+ </ComponentWithNamedBlocks >
You can’t perform that action at this time.
0 commit comments