Avoid computation of code blocks search in template if no callback
This commit is contained in:
parent
36151c128c
commit
27eefb7da3
|
@ -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,12 +60,10 @@ 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);
|
||||
}
|
||||
}
|
||||
})();
|
||||
(function() {
|
||||
const res = Array.from(tpl.matchAll(/\{(t|s):[^\{\}]+}/g));
|
||||
|
|
Loading…
Reference in New Issue