10 lines
316 B
JavaScript
10 lines
316 B
JavaScript
export default function embedInlineCalculations(string, calculations){
|
|
if (!string) return '';
|
|
if (!calculations) return string;
|
|
let index = 0;
|
|
return string.replace(/\{([^{}]*)\}/g, () => {
|
|
let comp = calculations && calculations[index++];
|
|
return comp && comp.result ? comp.result : string;
|
|
});
|
|
}
|