10 lines
314 B
JavaScript
10 lines
314 B
JavaScript
|
|
window.WBUtils = (() => {
|
||
|
|
function renderTemplate(template, data = {}) {
|
||
|
|
return String(template).replace(/\{\{\s*([a-zA-Z0-9_]+)\s*\}\}/g, (_, key) => {
|
||
|
|
return Object.prototype.hasOwnProperty.call(data, key) ? String(data[key]) : "";
|
||
|
|
});
|
||
|
|
}
|
||
|
|
|
||
|
|
return { renderTemplate };
|
||
|
|
})();
|