Skip to content

Commit

Permalink
fix(migrations): cf migration - stop removing empty newlines from i18…
Browse files Browse the repository at this point in the history
…n 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
  • Loading branch information
thePunderWoman committed Dec 15, 2023
1 parent c987945 commit 7bb312f
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
Expand Up @@ -628,7 +628,7 @@ export function formatTemplate(tmpl: string, templateType: string): string {
lineWasMigrated = true;
}
if ((line.trim() === '' && index !== 0 && index !== lines.length - 1) &&
(inMigratedBlock || lineWasMigrated)) {
(inMigratedBlock || lineWasMigrated) && !inI18nBlock) {
// skip blank lines except if it's the first line or last line
// this preserves leading and trailing spaces if they are already present
continue;
Expand Down
2 changes: 2 additions & 0 deletions packages/core/schematics/test/control_flow_migration_spec.ts
Expand Up @@ -4729,6 +4729,7 @@ describe('control flow migration', () => {
`</p>`,
`<span *ngIf="show;else elseBlock" i18n>Content here</span>`,
`<ng-template #elseBlock i18n>`,
` `,
` <p>Else Content</p>`,
`</ng-template>`,
`</div>`,
Expand All @@ -4745,6 +4746,7 @@ describe('control flow migration', () => {
` <span i18n>Content here</span>`,
` } @else {`,
` <ng-container i18n>`,
` `,
` <p>Else Content</p>`,
`</ng-container>`,
` }`,
Expand Down

0 comments on commit 7bb312f

Please sign in to comment.