emberjs/ember.js · error
Unexpected named block inside <:${name.chars}> named block:
Error message
Unexpected named block inside <:${name.chars}> named block: named blocks cannot contain nested named blocks What it means
Named blocks cannot be nested inside other named blocks. When normalizing children of a `<:name>` block, any nested named block triggers this error because the yielded-block structure is flat.
Source
Thrown at packages/@glimmer/syntax/lib/v2/normalize.ts:939
constructor(
private el: BuildElement,
loc: SourceSpan,
children: (ASTv2.ContentNode | ASTv2.NamedBlock)[],
block: BlockContext
) {
super(loc, children, block);
}
assertNamedBlock(name: SourceSlice, table: BlockSymbolTable): ASTv2.NamedBlock {
if (this.el.base.selfClosing) {
throw generateSyntaxError(
`<:${name.chars}/> is not a valid named block: named blocks cannot be self-closing`,
this.loc
);
}
if (isPresentArray(this.namedBlocks)) {
throw generateSyntaxError(
`Unexpected named block inside <:${name.chars}> named block: named blocks cannot contain nested named blocks`,
this.loc
);
}
if (!isLowerCase(name.chars)) {
throw generateSyntaxError(
`<:${name.chars}> is not a valid named block, and named blocks must begin with a lowercase letter`,
this.loc
);
}
if (
this.el.base.attrs.length > 0 ||
this.el.base.componentArgs.length > 0 ||
this.el.base.modifiers.length > 0
) {
throw generateSyntaxError(View on GitHub (pinned to 26f97246a8)
Solutions
- Flatten the named blocks so each is a direct child of the component element.
- Use distinct top-level named block names instead of nesting.
- Extract an inner component if you need hierarchical block structure.
Example fix
// before <Card><:body><:inner>x</:inner></:body></Card> // after <Card><:body>x</:body><:inner>y</:inner></Card>
Defensive patterns
Strategy: validation
Validate before calling
// Named blocks must be flat, one level deep.
function assertNoNestedNamedBlocks(namedBlock) {
if (namedBlock.children.some(c => c.type === 'named-block')) {
throw new Error(`Nested named block inside <:${namedBlock.name}>`);
}
} Prevention
- Keep named blocks one level deep under the component tag.
- Model hierarchy with separate components rather than nested named blocks.
- Use distinct names for sibling yielded sections.
When it happens
Trigger: Compiling a template like `<Card><:body><:inner>x</:inner></:body></Card>` — a `<:...>` block inside another `<:...>` block.
Common situations: Trying to group named blocks hierarchically; copy-paste nesting mistakes when composing deeply structured component APIs.
Related errors
- Unexpected named block at the top-level of a template
- Unexpected named block nested in a normal block
- <:${name.chars}/> is not a valid named block: named blocks c
- named block <:${name.chars}> cannot have attributes, argumen
- You used ${variable}.${tail.join('.')} as a tag name, but ${
AI-assisted analysis of emberjs/ember.js@26f97246a8 (2026-09-01).
Data as JSON: /api/errors/58033c8b3c052ccd.
Report an issue: GitHub.