Revert to get/set/add order for variable macro

This commit is contained in:
Cohee 2023-11-25 22:02:40 +02:00
parent b24d4f2340
commit 0bbaeeaedd
1 changed files with 12 additions and 12 deletions

View File

@ -96,6 +96,12 @@ export function replaceVariableMacros(input) {
continue; continue;
} }
// Replace {{getvar::name}} with the value of the variable name
line = line.replace(/{{getvar::([^}]+)}}/gi, (_, name) => {
name = name.trim();
return getLocalVariable(name);
});
// Replace {{setvar::name::value}} with empty string and set the variable name to value // Replace {{setvar::name::value}} with empty string and set the variable name to value
line = line.replace(/{{setvar::([^:]+)::([^}]+)}}/gi, (_, name, value) => { line = line.replace(/{{setvar::([^:]+)::([^}]+)}}/gi, (_, name, value) => {
name = name.trim(); name = name.trim();
@ -103,12 +109,6 @@ export function replaceVariableMacros(input) {
return ''; return '';
}); });
// Replace {{getvar::name}} with the value of the variable name
line = line.replace(/{{getvar::([^}]+)}}/gi, (_, name) => {
name = name.trim();
return getLocalVariable(name);
});
// Replace {{addvar::name::value}} with empty string and add value to the variable value // Replace {{addvar::name::value}} with empty string and add value to the variable value
line = line.replace(/{{addvar::([^:]+)::([^}]+)}}/gi, (_, name, value) => { line = line.replace(/{{addvar::([^:]+)::([^}]+)}}/gi, (_, name, value) => {
name = name.trim(); name = name.trim();
@ -116,6 +116,12 @@ export function replaceVariableMacros(input) {
return ''; return '';
}); });
// Replace {{getglobalvar::name}} with the value of the global variable name
line = line.replace(/{{getglobalvar::([^}]+)}}/gi, (_, name) => {
name = name.trim();
return getGlobalVariable(name);
});
// Replace {{setglobalvar::name::value}} with empty string and set the global variable name to value // Replace {{setglobalvar::name::value}} with empty string and set the global variable name to value
line = line.replace(/{{setglobalvar::([^:]+)::([^}]+)}}/gi, (_, name, value) => { line = line.replace(/{{setglobalvar::([^:]+)::([^}]+)}}/gi, (_, name, value) => {
name = name.trim(); name = name.trim();
@ -123,12 +129,6 @@ export function replaceVariableMacros(input) {
return ''; return '';
}); });
// Replace {{getglobalvar::name}} with the value of the global variable name
line = line.replace(/{{getglobalvar::([^}]+)}}/gi, (_, name) => {
name = name.trim();
return getGlobalVariable(name);
});
// Replace {{addglobalvar::name::value}} with empty string and add value to the global variable value // Replace {{addglobalvar::name::value}} with empty string and add value to the global variable value
line = line.replace(/{{addglobalvar::([^:]+)::([^}]+)}}/gi, (_, name, value) => { line = line.replace(/{{addglobalvar::([^:]+)::([^}]+)}}/gi, (_, name, value) => {
name = name.trim(); name = name.trim();