enable piped argument on function calls (#233)

This commit is contained in:
Jabi 2021-04-14 10:00:44 +02:00 committed by GitHub
parent acdffe0121
commit 17dfbbed84
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 1 deletions

View File

@ -9,7 +9,8 @@ import {
Binary, Binary,
LiteralMap, LiteralMap,
LiteralArray, LiteralArray,
Interpolation Interpolation,
MethodCall
} from '@angular/compiler'; } from '@angular/compiler';
import { ParserInterface } from './parser.interface'; import { ParserInterface } from './parser.interface';
@ -131,6 +132,10 @@ export class PipeParser implements ParserInterface {
return this.getTranslatablesFromAsts(ast.expressions); return this.getTranslatablesFromAsts(ast.expressions);
} }
if (ast instanceof MethodCall) {
return this.getTranslatablesFromAsts(ast.args);
}
return []; return [];
} }

View File

@ -195,4 +195,10 @@ describe('PipeParser', () => {
const keys = parser.extract(contents, templateFilename).keys(); const keys = parser.extract(contents, templateFilename).keys();
expect(keys).to.deep.equal([]); 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`]);
});
}); });