diff --git a/libs/transloco/src/lib/tests/transpiler.spec.ts b/libs/transloco/src/lib/tests/transpiler.spec.ts index 5485de8d..32795231 100644 --- a/libs/transloco/src/lib/tests/transpiler.spec.ts +++ b/libs/transloco/src/lib/tests/transpiler.spec.ts @@ -40,6 +40,11 @@ describe('TranslocoTranspiler', () => { expect(parsed).toEqual('LOWERCASE'); }); + it('should work with multiple functions', () => { + const parsed = parser.transpile('first [[ upperCase(second) ]] third [[ upperCase(fourth) ]] fifth', {}, {}, 'key'); + expect(parsed).toEqual('first SECOND third FOURTH fifth'); + }); + it('should pass the function params', () => { const spy = spyOn(transpilerFunctions['upperCase'], 'transpile'); parser.transpile('[[ upperCase(lowercase) ]]', {}, {}, 'key'); diff --git a/libs/transloco/src/lib/transloco.transpiler.ts b/libs/transloco/src/lib/transloco.transpiler.ts index dbbe1e58..ee6b2df1 100644 --- a/libs/transloco/src/lib/transloco.transpiler.ts +++ b/libs/transloco/src/lib/transloco.transpiler.ts @@ -167,7 +167,7 @@ export class FunctionalTranspiler let transpiled = value; if (isString(value)) { transpiled = value.replace( - /\[\[\s*(\w+)\((.*)\)\s*]]/g, + /\[\[\s*(\w+)\((.*?)\)\s*]]/g, (match: string, functionName: string, args: string) => { try { const func: TranslocoTranspilerFunction =