Skip to content

Commit

Permalink
Add support for Angular 15 self-closing-tags
Browse files Browse the repository at this point in the history
  • Loading branch information
tomcek112 committed Sep 30, 2023
1 parent f63c429 commit 6a0748d
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/cli/src/api/parsers/angularHTML.js
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ function parseHTMLTemplateFile(HASHES, filename, relativeFile, options) {
}

const data = fs.readFileSync(filename, 'utf8');
const { rootNodes, errors } = ngHtmlParser.parse(data);
const { rootNodes, errors } = ngHtmlParser.parse(data, { canSelfClose: true });
if (errors.length) return;

parseTemplateNode(rootNodes);
Expand Down
10 changes: 10 additions & 0 deletions packages/cli/test/api/extract.hashedkeys.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -443,6 +443,16 @@ describe('extractPhrases with hashed keys', () => {
},
string: '{var4}',
},
'text.inside-self-closing-tag': {
meta: {
context: [],
occurrences: [
'angular-template.html',
],
tags: [],
},
string: 'This is some text inside a self-closing tag',
},
});
});

Expand Down
10 changes: 10 additions & 0 deletions packages/cli/test/api/extract.sourcekeys.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,16 @@ describe('extractPhrases with source keys', () => {
},
string: '{var4}',
},
'text.inside-self-closing-tag': {
meta: {
context: [],
occurrences: [
'angular-template.html',
],
tags: [],
},
string: 'This is some text inside a self-closing tag',
},
});
});

Expand Down
2 changes: 2 additions & 0 deletions packages/cli/test/fixtures/angular-template.html
Original file line number Diff line number Diff line change
Expand Up @@ -98,4 +98,6 @@ <h1 class="marginBottom-2x">
>
Content 1
</mat-tab>

<T str="This is some text inside a self-closing tag" key="text.inside-self-closing-tag" />
</div>

0 comments on commit 6a0748d

Please sign in to comment.