(str: string, getValue: GetVariableStringValue, options: VariableStringOptions = defaultOptions)
| 17 | * @param options Options used when splitting variable strings E.G open and close markers |
| 18 | */ |
| 19 | export function parseVariableString(str: string, getValue: GetVariableStringValue, options: VariableStringOptions = defaultOptions): string { |
| 20 | const arr = splitVariableString(str, options); |
| 21 | return (arr.length > 0) |
| 22 | ? arr.reduce((acc, val, index) => acc + ( |
| 23 | (index % 2 === 1) |
| 24 | ? getValue(val) |
| 25 | : val |
| 26 | )) |
| 27 | : ''; |
| 28 | } |
| 29 | |
| 30 | /** |
| 31 | * Split a "variable string" into an array. |
no test coverage detected