diff --git a/src/parsers/directive.parser.ts b/src/parsers/directive.parser.ts index 3b21558..c44a9dd 100644 --- a/src/parsers/directive.parser.ts +++ b/src/parsers/directive.parser.ts @@ -18,9 +18,11 @@ export class DirectiveParser extends AbstractTemplateParser implements ParserInt let collection: TranslationCollection = new TranslationCollection(); template = this._normalizeTemplateAttributes(template); + + const selector = '[translate], [ng2-translate]'; $(template) - .find('[translate], [ng2-translate]') - .addBack() + .find(selector) + .addBack(selector) .each((i: number, element: CheerioElement) => { const $element = $(element); const attr = $element.attr('translate') || $element.attr('ng2-translate'); diff --git a/tests/parsers/directive.parser.spec.ts b/tests/parsers/directive.parser.spec.ts index 003088b..499f608 100644 --- a/tests/parsers/directive.parser.spec.ts +++ b/tests/parsers/directive.parser.spec.ts @@ -98,4 +98,10 @@ describe('DirectiveParser', () => { expect(keys).to.deep.equal(['KEY']); }); + it('should not extract translate pipe in html tag', () => { + const contents = `
{{ 'Audiobooks for personal development' | translate }}
`; + const collection = parser.extract(contents, templateFilename); + expect(collection.values).to.deep.equal({}); + }); + });