Skip to content

Commit

Permalink
enable piped argument on function calls (#233)
Browse files Browse the repository at this point in the history
  • Loading branch information
jabiinfante authored Apr 14, 2021
1 parent acdffe0 commit 17dfbbe
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/parsers/pipe.parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ import {
Binary,
LiteralMap,
LiteralArray,
Interpolation
Interpolation,
MethodCall
} from '@angular/compiler';

import { ParserInterface } from './parser.interface';
Expand Down Expand Up @@ -131,6 +132,10 @@ export class PipeParser implements ParserInterface {
return this.getTranslatablesFromAsts(ast.expressions);
}

if (ast instanceof MethodCall) {
return this.getTranslatablesFromAsts(ast.args);
}

return [];
}

Expand Down
6 changes: 6 additions & 0 deletions tests/parsers/pipe.parser.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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`]);
});
});

0 comments on commit 17dfbbe

Please sign in to comment.