|
|
@ -17,8 +17,10 @@ export function createTokenParser(format: string) { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
export function interpolate(text: string, params: string[]) { |
|
|
export function interpolate(text: string, params: string[]) { |
|
|
return text |
|
|
return text |
|
|
.replace(/(['"]?\{\s*(\d+)\s*\}['"]?)/g, (_, match, digit) => params[digit] ?? match) |
|
|
.replace(/(['"])?\{\s*(\d+)\s*\}\1/g, (_, quote, digit) => |
|
|
|
|
|
(quote ? quote : '') + (params[digit] ?? `{${digit}}`) + (quote ? quote : '') |
|
|
|
|
|
) |
|
|
.replace(/\s+/g, ' '); |
|
|
.replace(/\s+/g, ' '); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|