From 27eefb7da3ecd0fb2c8a2609cffb845f346a5600 Mon Sep 17 00:00:00 2001 From: Niko Date: Wed, 23 Feb 2022 20:00:14 +0100 Subject: [PATCH] Avoid computation of code blocks search in template if no callback --- web/src/app/js/app.js | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/web/src/app/js/app.js b/web/src/app/js/app.js index 25e560f..f093aae 100644 --- a/web/src/app/js/app.js +++ b/web/src/app/js/app.js @@ -50,6 +50,7 @@ app.template = { if (typeof data === 'string') data = { value: data }; (function() { + if (customCback === undefined) return; const res = tpl.match(/\{loop([^\{\}]+)?\}[.\s\S]+?{\/loop\}/g); if (res === null) return; for (var i = 0; i < res.length; i++) { @@ -59,11 +60,9 @@ app.template = { cnt = cnt.substr(0, cnt.lastIndexOf('{')).trim(); var k = res[i].trim(); k = k.substr(1, k.indexOf('}')-1).trim(); - if (customCback !== undefined) { - var newv = customCback(k, cnt); - if (typeof newv === 'string') - tpl = tpl.replace(original, newv); - } + var newv = customCback(k, cnt); + if (typeof newv === 'string') + tpl = tpl.replace(original, newv); } })(); (function() {