Moved inline cacultion regex to a constant to ensure constistency
This commit is contained in:
@@ -1,8 +1,10 @@
|
||||
import INLINE_CALCULATION_REGEX from '/imports/constants/INLINE_CALCULTION_REGEX.js';
|
||||
|
||||
export default function embedInlineCalculations(string, calculations){
|
||||
if (!string) return '';
|
||||
if (!calculations) return string;
|
||||
let index = 0;
|
||||
return string.replace(/\{([^{}]*)\}/g, () => {
|
||||
return string.replace(INLINE_CALCULATION_REGEX, () => {
|
||||
let comp = calculations && calculations[index++];
|
||||
return comp && comp.result ? comp.result : string;
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user