Skip to content

Commit e73205f

Browse files
fix(migrations): cf migration - stop removing empty newlines from i18n blocks (#53578)
Since i18n sections are whitespace sensitive, we should avoid removing empty lines when inside an i18n block that were present before. PR Close #53578
1 parent 7fde3ef commit e73205f

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

packages/core/schematics/ng-generate/control-flow-migration/util.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -628,7 +628,7 @@ export function formatTemplate(tmpl: string, templateType: string): string {
628628
lineWasMigrated = true;
629629
}
630630
if ((line.trim() === '' && index !== 0 && index !== lines.length - 1) &&
631-
(inMigratedBlock || lineWasMigrated)) {
631+
(inMigratedBlock || lineWasMigrated) && !inI18nBlock) {
632632
// skip blank lines except if it's the first line or last line
633633
// this preserves leading and trailing spaces if they are already present
634634
continue;

packages/core/schematics/test/control_flow_migration_spec.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4729,6 +4729,7 @@ describe('control flow migration', () => {
47294729
`</p>`,
47304730
`<span *ngIf="show;else elseBlock" i18n>Content here</span>`,
47314731
`<ng-template #elseBlock i18n>`,
4732+
` `,
47324733
` <p>Else Content</p>`,
47334734
`</ng-template>`,
47344735
`</div>`,
@@ -4745,6 +4746,7 @@ describe('control flow migration', () => {
47454746
` <span i18n>Content here</span>`,
47464747
` } @else {`,
47474748
` <ng-container i18n>`,
4749+
` `,
47484750
` <p>Else Content</p>`,
47494751
`</ng-container>`,
47504752
` }`,

0 commit comments

Comments
 (0)