Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add regex for additional whitespaces in Angular template pipe syntax in CLI #171

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions packages/cli/src/api/parsers/angularHTML.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,17 @@ const { createPayload, isPayloadValid } = require('./utils');
/**
* Global regexp to find use of TranslatePipe.
*/
const pipeRegexpG = /{{\s*?['|"]([\s\S]+?)['|"]\s*?\|\s*?translate\s*?:?({[\s\S]*?})?\s*?}}/gi;
const pipeRegexpG = /{{\s*?['|"]([\s\S]+?)['|"]\s*?\|\s*?translate\s*?:?\s*?({[\s\S]*?})?\s*?}}/gi;

/**
* Regexp to find use of TranslatePipe and match with capture groups.
*/
const pipeRegexp = /{{\s*?['|"]([\s\S]+?)['|"]\s*?\|\s*?translate\s*?:?({[\s\S]*?})?\s*?}}/i;
const pipeRegexp = /{{\s*?['|"]([\s\S]+?)['|"]\s*?\|\s*?translate\s*?:?\s*?({[\s\S]*?})?\s*?}}/i;

/**
* Regexp to find use of TranslatePipe in Attributes;
*/
const pipeBindingRegexp = /'([\s\S]+?)'\s*?\|\s*?translate\s*?:?({[\s\S]*?})?/i;
const pipeBindingRegexp = /'([\s\S]+?)'\s*?\|\s*?translate\s*?:?\s*?({[\s\S]*?})?/i;

/**
* Loosely parses string (from HTML) to an object.
Expand Down
4 changes: 4 additions & 0 deletions packages/cli/test/api/extract.hashedkeys.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,10 @@ describe('extractPhrases with hashed keys', () => {
string: 'This is a sixth pipe text, no one should do this',
meta: { context: [], tags: [], occurrences: ['angular-template.html'] },
},
'text.pipe_text_seventh': {
string: 'This is a seventh pipe test for additional white spaces',
meta: { context: [], tags: [], occurrences: ['angular-template.html'] },
},
'867b7cc4643da9b4c97ababa43c50c23': {
string: 'Used in a {binding}',
meta: { context: [], tags: [], occurrences: ['angular-template.html'] },
Expand Down
4 changes: 4 additions & 0 deletions packages/cli/test/api/extract.sourcekeys.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,10 @@ describe('extractPhrases with source keys', () => {
string: 'This is a sixth pipe text, no one should do this',
meta: { context: [], tags: [], occurrences: ['angular-template.html'] },
},
'text.pipe_text_seventh': {
string: 'This is a seventh pipe test for additional white spaces',
meta: { context: [], tags: [], occurrences: ['angular-template.html'] },
},
'Used in a {binding}': {
string: 'Used in a {binding}',
meta: { context: [], tags: [], occurrences: ['angular-template.html'] },
Expand Down
4 changes: 4 additions & 0 deletions packages/cli/test/fixtures/angular-template.html
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ <h1 class="marginBottom-2x">
}}}
</p>

<p class="using-pipe-third">
{{ "This is a seventh pipe test for additional white spaces" | translate: { key: "text.pipe_text_seventh" } }}
</p>

<p [matTooltip]="'Used in a {binding}' | translate">
Inside a p
</p>
Expand Down