diff --git a/changelog_unreleased/angular/19499.md b/changelog_unreleased/angular/19499.md new file mode 100644 index 000000000..01d08f675 --- /dev/null +++ b/changelog_unreleased/angular/19499.md @@ -0,0 +1,37 @@ +#### Format `@content(name)` -> `@content (name)` to align with other block syntax (#19499 by @fisker) + + +```html + + + @content (icon) { + Icon! + } + @content (description) { + Description text + } + Other children + + + + + @content(icon) { + Icon! + } + @content(description) { + Description text + } + Other children + + + + + @content (icon) { + Icon! + } + @content (description) { + Description text + } + Other children + +``` diff --git a/src/language-html/print/angular-control-flow-block.js b/src/language-html/print/angular-control-flow-block.js index 95eafa604..6281a5c1b 100644 --- a/src/language-html/print/angular-control-flow-block.js +++ b/src/language-html/print/angular-control-flow-block.js @@ -10,8 +10,6 @@ import { hasPrettierIgnore } from "../utilities/index.js"; import { ANGULAR_CONTROL_FLOW_BLOCK_SETTINGS } from "./angular-control-flow-block-settings.evaluate.js"; import { printChildren } from "./children.js"; -const blocksShouldNotPrintSpaceAfterName = new Set(["content"]); - function printAngularControlFlowBlock(path, options, print) { const { node } = path; const docs = []; @@ -28,12 +26,7 @@ function printAngularControlFlowBlock(path, options, print) { } if (node.parameters) { - docs.push( - blocksShouldNotPrintSpaceAfterName.has(node.name) ? "" : " ", - "(", - group(print("parameters")), - ")", - ); + docs.push(" ", "(", group(print("parameters")), ")"); } if (!isSwitchFallthroughCase(node)) { diff --git a/tests/format/angular/control-flow/__snapshots__/format.test.js.snap b/tests/format/angular/control-flow/__snapshots__/format.test.js.snap index 00682d5a2..deac6b286 100644 --- a/tests/format/angular/control-flow/__snapshots__/format.test.js.snap +++ b/tests/format/angular/control-flow/__snapshots__/format.test.js.snap @@ -90,17 +90,65 @@ parsers: ["angular"] Other children + + @content (items; let item, index) { + #{{index}}: {{item}} + } + + + + @content (renderHeader; let _) { + Header Content + } + + + + @content (renderRow; let row, idx, isLast) { + {{ idx }} - {{ row }} (Last: {{ isLast }}) + } + + + + @content (children; let result) { + {{ result }} + } + + =====================================output===================================== - @content(icon) { + @content (icon) { Icon! } - @content(description) { + @content (description) { Description text } Other children + + @content (items; let item, index) { + #{{ index }}: {{ item }} + } + + + + @content (renderHeader; let _) { + Header Content + } + + + + @content (renderRow; let row, idx, isLast) { + {{ idx }} - {{ row }} (Last: {{ isLast }}) + } + + + + @content (children; let result) { + {{ result }} + } + + ================================================================================ `; diff --git a/tests/format/angular/control-flow/content.html b/tests/format/angular/control-flow/content.html index 0e8e013fd..21bf3a8da 100644 --- a/tests/format/angular/control-flow/content.html +++ b/tests/format/angular/control-flow/content.html @@ -7,3 +7,27 @@ } Other children + + + @content (items; let item, index) { + #{{index}}: {{item}} + } + + + + @content (renderHeader; let _) { + Header Content + } + + + + @content (renderRow; let row, idx, isLast) { + {{ idx }} - {{ row }} (Last: {{ isLast }}) + } + + + + @content (children; let result) { + {{ result }} + } +