Fixed bug was only replacing first match

This commit is contained in:
Niko 2022-02-14 01:16:26 +01:00
parent 1c646d0528
commit e455b88de9
1 changed files with 6 additions and 4 deletions

View File

@ -31,10 +31,12 @@ app.template = {
.replace(/\}$/, ''));
}
for (var i = 0; i < matches.length; i++) {
const k = matches[0];
if (k.match(/^[a-zA-Z0-9_\.]+$/))
tpl = tpl.replaceAll('{.'+k+'}',
eval(`data.${k}`));
const k = matches[i];
if (k.match(/^[a-zA-Z0-9_\.]+$/)) {
const v = eval(`data.${k}`);
if (v !== undefined)
tpl = tpl.replaceAll('{.'+k+'}',v);
}
}
return tpl;
},