Fix bug in PipeParser
This commit is contained in:
parent
7822916e28
commit
fcd37fd000
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@biesbjerg/ng2-translate-extract",
|
||||
"version": "0.5.0",
|
||||
"version": "0.5.1",
|
||||
"description": "Extract strings from projects using ng2-translate",
|
||||
"main": "dist/index.js",
|
||||
"typings": "dist/index.d.ts",
|
||||
|
@ -15,7 +15,7 @@ export class PipeParser extends AbstractTemplateParser implements ParserInterfac
|
||||
protected _parseTemplate(template: string): TranslationCollection {
|
||||
let collection: TranslationCollection = new TranslationCollection();
|
||||
|
||||
const regExp: RegExp = /(['"`])([^\1\r\n]*?)\1\s*\|\s*translate/g;
|
||||
const regExp: RegExp = /(['"`])([^>\1\r\n]*?)\1\s*\|\s*translate/g;
|
||||
let matches: RegExpExecArray;
|
||||
while (matches = regExp.exec(template)) {
|
||||
collection = collection.add(matches[2]);
|
||||
|
@ -12,6 +12,12 @@ describe('PipeParser', () => {
|
||||
parser = new PipeParser();
|
||||
});
|
||||
|
||||
it('should only extract string using pipe', () => {
|
||||
const contents = `<button [style.background]="'lime'">{{ 'SomeKey_NotWorking' | translate }}</button>`;
|
||||
const keys = parser.extract(contents, templateFilename).keys();
|
||||
expect(keys).to.deep.equal(['SomeKey_NotWorking']);
|
||||
});
|
||||
|
||||
it('should extract interpolated strings using translate pipe', () => {
|
||||
const contents = `Hello {{ 'World' | translate }}`;
|
||||
const keys = parser.extract(contents, templateFilename).keys();
|
||||
|
Loading…
x
Reference in New Issue
Block a user