I have the following that is iterating over an array of "templateOverrides". DPGlobal.template
is the original template which I need to override. My issue is that I need to pass the g
flag to the .replace()
method on the var newTemplate = ...
line. It's working insofar as I am able to dynamically iterate through and override template pieces one at a time, but the g
flag is not passed. I'm mainly curious what is the most DRY method of achieving it...
for ( var i in templateOverrides ) {
var thisOverride = templateOverrides[i];
var origGlobalTemplate = DPGlobal[thisOverride];
var newTemplate = DPGlobal.template.replace(origGlobalTemplate, options[thisOverride]);
DPGlobal.template = newTemplate;
i++;
}