Fix bug in template handling
This commit is contained in:
parent
a89860815f
commit
2c4271c9f4
@ -230,16 +230,29 @@ class {
|
|||||||
str = str.substr(str.indexOf('(')+1);
|
str = str.substr(str.indexOf('(')+1);
|
||||||
while(str) {
|
while(str) {
|
||||||
let index = 0;
|
let index = 0;
|
||||||
let stack = [];
|
let parens = 0;
|
||||||
|
let quote = false;
|
||||||
while(str[index]) {
|
while(str[index]) {
|
||||||
if(",)".includes(str[index]) && !stack.length) break;
|
let c = str[index++];
|
||||||
if(str[index] == '(') stack.push(')');
|
|
||||||
if(stack[stack.length - 1] === str[index]) stack.pop();
|
if(c === quote && index > 1 && str[index-2] !== "\\")
|
||||||
else if(`"'`.includes(str[index])) stack.push(str[index]);
|
quote = false;
|
||||||
index = index + 1;
|
else if(`"'`.includes(c))
|
||||||
|
quote = c;
|
||||||
|
if(quote) continue;
|
||||||
|
|
||||||
|
if(c === '(')
|
||||||
|
parens = parens + 1;
|
||||||
|
else if(c === ')') {
|
||||||
|
parens = parens - 1;
|
||||||
|
continue
|
||||||
}
|
}
|
||||||
args.push(str.substr(0, index).trim());
|
if(parens > 0) continue;
|
||||||
str = str.substr(index+1);
|
|
||||||
|
if(",)".includes(c)) break;
|
||||||
|
}
|
||||||
|
args.push(str.substr(0, index-1).trim());
|
||||||
|
str = str.substr(index);
|
||||||
}
|
}
|
||||||
return args;
|
return args;
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user