Browse Source

Interpolator fixed.

pull/351/head
Sebastian 7 years ago
parent
commit
c82d9fa550
  1. 6
      src/Squidex/app/framework/utils/interpolator.spec.ts
  2. 2
      src/Squidex/app/framework/utils/interpolator.ts

6
src/Squidex/app/framework/utils/interpolator.spec.ts

@ -21,6 +21,12 @@ describe('interpolate', () => {
expect(result).toEqual('hello world');
});
it('should interpolate with multiple object values', () => {
const result = interpolate('hello ${string1}${string2}', { string1: 'world', string2: '!' });
expect(result).toEqual('hello world!');
});
it('should interpolate with array value', () => {
const result = interpolate('hello ${1}', ['my', 'world']);

2
src/Squidex/app/framework/utils/interpolator.ts

@ -8,7 +8,7 @@
import { DateTime } from './date-time';
import { Types } from './types';
const regex = /\${[^}]+}/;
const regex = /\${[^}]+}/g;
export function interpolate(pattern: string, value?: any, shortcut?: string, fallback = 'undefined'): string {
const result = pattern.replace(regex, (match: string) => {

Loading…
Cancel
Save