From 17dfbbed843336ccc67de9f3d18b6aba33dcfe5d Mon Sep 17 00:00:00 2001 From: Jabi Date: Wed, 14 Apr 2021 10:00:44 +0200 Subject: [PATCH] enable piped argument on function calls (#233) --- src/parsers/pipe.parser.ts | 7 ++++++- tests/parsers/pipe.parser.spec.ts | 6 ++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/parsers/pipe.parser.ts b/src/parsers/pipe.parser.ts index 73a2c89..fb1dfb2 100644 --- a/src/parsers/pipe.parser.ts +++ b/src/parsers/pipe.parser.ts @@ -9,7 +9,8 @@ import { Binary, LiteralMap, LiteralArray, - Interpolation + Interpolation, + MethodCall } from '@angular/compiler'; import { ParserInterface } from './parser.interface'; @@ -131,6 +132,10 @@ export class PipeParser implements ParserInterface { return this.getTranslatablesFromAsts(ast.expressions); } + if (ast instanceof MethodCall) { + return this.getTranslatablesFromAsts(ast.args); + } + return []; } diff --git a/tests/parsers/pipe.parser.spec.ts b/tests/parsers/pipe.parser.spec.ts index ba5e3ab..861ab04 100644 --- a/tests/parsers/pipe.parser.spec.ts +++ b/tests/parsers/pipe.parser.spec.ts @@ -195,4 +195,10 @@ describe('PipeParser', () => { const keys = parser.extract(contents, templateFilename).keys(); expect(keys).to.deep.equal([]); }); + + it('should extract strings from piped arguments inside a function calls on templates', () => { + const contents = `{{ callMe('Hello' | translate, 'World' | translate ) }}`; + const keys = parser.extract(contents, templateFilename).keys(); + expect(keys).to.deep.equal([`Hello`, `World`]); + }); });