[handlebars] Named blocks can't be self closing (#11900)
This commit is contained in:
1 parent
d09545952e
commit
d3dfb74cab
4 files changed
+54
No files matched your search
@@ -0,0 +1,23 @@
|
||||
#### Support Glimmer's named blocks (#11899 by @duailibe)
|
||||
|
||||
Prettier already supported this feature, but it converted empty named blocks to self-closing, which is not supported by the Glimmer compiler.
|
||||
|
||||
See: [Glimmer's named blocks](https://emberjs.github.io/rfcs/0460-yieldable-named-blocks.html).
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
```hbs
|
||||
// Input
|
||||
<Component>
|
||||
<:named></:named>
|
||||
</Component>
|
||||
|
||||
// Prettier stable
|
||||
<Component>
|
||||
<:named />
|
||||
</Component>
|
||||
|
||||
// Prettier main
|
||||
<Component>
|
||||
<:named></:named>
|
||||
</Component>
|
||||
```
|
||||
@@ -32,6 +32,7 @@ function isGlimmerComponent(node) {
|
||||
return (
|
||||
isNodeOfSomeType(node, ["ElementNode"]) &&
|
||||
typeof node.tag === "string" &&
|
||||
node.tag[0] !== ":" &&
|
||||
(isUppercase(node.tag[0]) || node.tag.includes("."))
|
||||
);
|
||||
}
|
||||
|
||||
@@ -93,6 +93,30 @@ printWidth: 80
|
||||
================================================================================
|
||||
`;
|
||||
|
||||
exports[`named-block.hbs format 1`] = `
|
||||
====================================options=====================================
|
||||
parsers: ["glimmer"]
|
||||
printWidth: 80
|
||||
| printWidth
|
||||
=====================================input======================================
|
||||
<ComponentWithNamedBlocks>
|
||||
<:first-named-block></:first-named-block>
|
||||
<:second-named-block> </:second-named-block>
|
||||
<:named-block-with-comment>{{! Do not convert to an empty element}}</:named-block-with-comment>
|
||||
<:named-block-with-content>Hello</:named-block-with-content>
|
||||
</ComponentWithNamedBlocks>
|
||||
|
||||
=====================================output=====================================
|
||||
<ComponentWithNamedBlocks>
|
||||
<:first-named-block></:first-named-block>
|
||||
<:second-named-block> </:second-named-block>
|
||||
<:named-block-with-comment
|
||||
>{{! Do not convert to an empty element}}</:named-block-with-comment>
|
||||
<:named-block-with-content>Hello</:named-block-with-content>
|
||||
</ComponentWithNamedBlocks>
|
||||
================================================================================
|
||||
`;
|
||||
|
||||
exports[`nested-path.hbs format 1`] = `
|
||||
====================================options=====================================
|
||||
parsers: ["glimmer"]
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
<ComponentWithNamedBlocks>
|
||||
<:first-named-block></:first-named-block>
|
||||
<:second-named-block> </:second-named-block>
|
||||
<:named-block-with-comment>{{! Do not convert to an empty element}}</:named-block-with-comment>
|
||||
<:named-block-with-content>Hello</:named-block-with-content>
|
||||
</ComponentWithNamedBlocks>
|
||||
Reference in new issue
Block a user