diff --git a/public/script.js b/public/script.js index aac06febd..dd4234405 100644 --- a/public/script.js +++ b/public/script.js @@ -526,14 +526,17 @@ function getUrlSync(url, cache = true) { }).responseText; } -const templateCache = {}; +const templateCache = new Map(); export function renderTemplate(templateId, templateData = {}, sanitize = true, localize = true, fullPath = false) { try { const pathToTemplate = fullPath ? templateId : `/scripts/templates/${templateId}.html`; - const templateContent = (pathToTemplate in templateCache) ? templateCache[pathToTemplate] : getUrlSync(pathToTemplate); - templateCache[pathToTemplate] = templateContent; - const template = Handlebars.compile(templateContent); + let template = templateCache.get(pathToTemplate); + if (!template) { + const templateContent = getUrlSync(pathToTemplate); + template = Handlebars.compile(templateContent); + templateCache.set(pathToTemplate, template); + } let result = template(templateData); if (sanitize) {