Angular: Format @content(name) -> @content (name) to align with other block syntax (#19499)

This commit is contained in:
fisker Cheung authored and GitHub committed 2026-06-30 09:05:20 +08:00
1 parent abed2c22db
commit 2e92ac0ee2
4 files changed
+112 -10

No files matched your search

+37
View File
@@ -0,0 +1,37 @@
#### Format `@content(name)` -> `@content (name)` to align with other block syntax (#19499 by @fisker)
<!-- prettier-ignore -->
```html
<!-- Input -->
<FancyButton [label]="title">
@content (icon) {
<span>Icon!</span>
}
@content (description) {
<span>Description text</span>
}
<span>Other children</span>
</FancyButton>
<!-- Prettier stable -->
<FancyButton [label]="title">
@content(icon) {
<span>Icon!</span>
}
@content(description) {
<span>Description text</span>
}
<span>Other children</span>
</FancyButton>
<!-- Prettier main -->
<FancyButton [label]="title">
@content (icon) {
<span>Icon!</span>
}
@content (description) {
<span>Description text</span>
}
<span>Other children</span>
</FancyButton>
```
+1 -8
View File
@@ -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)) {
@@ -90,17 +90,65 @@ parsers: ["angular"]
<span>Other children</span>
</FancyButton>
<FancyButton [label]="title">
@content (items; let item, index) {
<span>#{{index}}: {{item}}</span>
}
</FancyButton>
<FancyList>
@content (renderHeader; let _) {
<span>Header Content</span>
}
</FancyList>
<FancyTable>
@content (renderRow; let row, idx, isLast) {
<span>{{ idx }} - {{ row }} (Last: {{ isLast }})</span>
}
</FancyTable>
<DynamicIf [injector]="injector" [cond]="visible">
@content (children; let result) {
<child>{{ result }}</child>
}
</DynamicIf>
=====================================output=====================================
<FancyButton [label]="title">
@content(icon) {
@content (icon) {
<span>Icon!</span>
}
@content(description) {
@content (description) {
<span>Description text</span>
}
<span>Other children</span>
</FancyButton>
<FancyButton [label]="title">
@content (items; let item, index) {
<span>#{{ index }}: {{ item }}</span>
}
</FancyButton>
<FancyList>
@content (renderHeader; let _) {
<span>Header Content</span>
}
</FancyList>
<FancyTable>
@content (renderRow; let row, idx, isLast) {
<span>{{ idx }} - {{ row }} (Last: {{ isLast }})</span>
}
</FancyTable>
<DynamicIf [injector]="injector" [cond]="visible">
@content (children; let result) {
<child>{{ result }}</child>
}
</DynamicIf>
================================================================================
`;
@@ -7,3 +7,27 @@
}
<span>Other children</span>
</FancyButton>
<FancyButton [label]="title">
@content (items; let item, index) {
<span>#{{index}}: {{item}}</span>
}
</FancyButton>
<FancyList>
@content (renderHeader; let _) {
<span>Header Content</span>
}
</FancyList>
<FancyTable>
@content (renderRow; let row, idx, isLast) {
<span>{{ idx }} - {{ row }} (Last: {{ isLast }})</span>
}
</FancyTable>
<DynamicIf [injector]="injector" [cond]="visible">
@content (children; let result) {
<child>{{ result }}</child>
}
</DynamicIf>