From e455b88de98657bd4a42e3c4b0f9e6b7878bafd6 Mon Sep 17 00:00:00 2001 From: Niko Date: Mon, 14 Feb 2022 01:16:26 +0100 Subject: [PATCH] Fixed bug was only replacing first match --- web/src/app/js/app.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/web/src/app/js/app.js b/web/src/app/js/app.js index 348fe3f..4a5d899 100644 --- a/web/src/app/js/app.js +++ b/web/src/app/js/app.js @@ -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; },