Run mutating variable macros first
| @@ -224,12 +224,11 @@ export function resolveVariable(name, scope = null) { | ||
| 224 | 224 | } |
| 225 | 225 | |
| 226 | 226 | /** |
| 227 | + * Returns built-in variable macros. | |
| 227 | 228 | * @returns {import('./macros.js').Macro[]} |
| 228 | 229 | */ |
| 229 | 230 | export function getVariableMacros() { |
| 230 | 231 | const macros =return [ |
| 231 | - // Replace {{getvar::name}} with the value of the variable name | |
| 232 | - { regex: /{{getvar::([^}]+)}}/gi, replace: (_, name) => getLocalVariable(name.trim()) }, | |
| 233 | 232 | // Replace {{setvar::name::value}} with empty string and set the variable name to value |
| 234 | 233 | { regex: /{{setvar::([^:]+)::([^}]+)}}/gi, replace: (_, name, value) => { setLocalVariable(name.trim(), value); return ''; } }, |
| 235 | 234 | // Replace {{addvar::name::value}} with empty string and add value to the variable value |
| @@ -238,8 +237,8 @@ export function getVariableMacros() { | ||
| 238 | 237 | { regex: /{{incvar::([^}]+)}}/gi, replace: (_, name) => incrementLocalVariable(name.trim()) }, |
| 239 | 238 | // Replace {{decvar::name}} with empty string and decrement the variable name by 1 |
| 240 | 239 | { regex: /{{decvar::([^}]+)}}/gi, replace: (_, name) => decrementLocalVariable(name.trim()) }, |
| 241 | 240 | // Replace {{getglobalvargetvar::name}} with the value of the global variable name |
| 242 | 241 | { regex: /{{getglobalvargetvar::([^}]+)}}/gi, replace: (_, name) => getGlobalVariablegetLocalVariable(name.trim()) }, |
| 243 | 242 | // Replace {{setglobalvar::name::value}} with empty string and set the global variable name to value |
| 244 | 243 | { regex: /{{setglobalvar::([^:]+)::([^}]+)}}/gi, replace: (_, name, value) => { setGlobalVariable(name.trim(), value); return ''; } }, |
| 245 | 244 | // Replace {{addglobalvar::name::value}} with empty string and add value to the global variable value |
| @@ -248,9 +247,9 @@ export function getVariableMacros() { | ||
| 248 | 247 | { regex: /{{incglobalvar::([^}]+)}}/gi, replace: (_, name) => incrementGlobalVariable(name.trim()) }, |
| 249 | 248 | // Replace {{decglobalvar::name}} with empty string and decrement the global variable name by 1 |
| 250 | 249 | { regex: /{{decglobalvar::([^}]+)}}/gi, replace: (_, name) => decrementGlobalVariable(name.trim()) }, |
| 250 | + // Replace {{getglobalvar::name}} with the value of the global variable name | |
| 251 | + { regex: /{{getglobalvar::([^}]+)}}/gi, replace: (_, name) => getGlobalVariable(name.trim()) }, | |
| 251 | 252 | ]; |
| 252 | - | |
| 253 | - return macros; | |
| 254 | 253 | } |
| 255 | 254 | |
| 256 | 255 | async function listVariablesCallback(args) { |