mirror of
https://github.com/Ylianst/MeshCentral.git
synced 2025-11-07 12:52:54 -05:00
allow system variables in footer, loginfooter, welcometext, title2 #6634
Signed-off-by: si458 <simonsmith5521@gmail.com>
This commit is contained in:
16
common.js
16
common.js
@@ -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;
|
||||
}
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user