Replace all occurences of escaped quotes.

This commit is contained in:
Kim Biesbjerg 2017-07-05 15:43:54 +02:00
parent 5259da8fe3
commit b2ae17697d
2 changed files with 7 additions and 1 deletions

View File

@ -18,7 +18,7 @@ export class PipeParser extends AbstractTemplateParser implements ParserInterfac
const regExp: RegExp = /(['"`])((?:(?!\1).|\\\1)+)\1\s*\|\s*translate/g;
let matches: RegExpExecArray;
while (matches = regExp.exec(template)) {
collection = collection.add(matches[2].replace('\\\'', '\''));
collection = collection.add(matches[2].split('\\\'').join('\''));
}
return collection;

View File

@ -36,6 +36,12 @@ describe('PipeParser', () => {
expect(keys).to.deep.equal([`World's largest potato`]);
});
it('should extract strings with multiple escaped quotes', () => {
const contents = `{{ 'C\\'est ok. C\\'est ok' | translate }}`;
const keys = parser.extract(contents, templateFilename).keys();
expect(keys).to.deep.equal([`C'est ok. C'est ok`]);
});
it('should extract interpolated strings using translate pipe in attributes', () => {
const contents = `<span attr="{{ 'Hello World' | translate }}"></span>`;
const keys = parser.extract(contents, templateFilename).keys();