How might this be improved, as it pertains to the loop and the regex replace?
var properties = { ... };
var template = element.innerHTML;
for (var name in properties) {
template = template.replace
(new RegExp('\\${' + name + '}', 'gm'), properties[name]);
}
element.innerHTML = template;
Is there a way I could get all the matches for /\$\{\w+\}/gm
and just use those to build a new string once for the entire operation?