allow system variables in footer, loginfooter, welcometext, title2 #6634

Signed-off-by: si458 <simonsmith5521@gmail.com>
This commit is contained in:
si458
2025-05-26 14:03:55 +01:00
parent 5fcffcd608
commit 89238303cb
3 changed files with 66 additions and 4 deletions

View File

@@ -419,4 +419,20 @@ module.exports.uniqueArray = function (a) {
}
}
return out;
}
// Replace placeholders in a string with values from an object or a function
module.exports.replacePlaceholders = function (template, values) {
return template.replace(/\{(\w+)\}/g, (match, key) => {
console.log('match', match, 'key', key, 'values', values);
if (typeof values === 'function') {
return values(key);
}
else if (values && typeof values === 'object') {
return values[key] !== undefined ? values[key] : match;
}
else {
return values !== undefined ? values : match;
}
});
}