Update handlebars cache

This commit is contained in:
toasted-nutbread 2019-12-20 21:51:34 -05:00
parent 2519f99f54
commit d7bf128333

View File

@ -141,12 +141,13 @@ function handlebarsRenderStatic(name, data) {
function handlebarsRenderDynamic(template, data) { function handlebarsRenderDynamic(template, data) {
handlebarsRegisterHelpers(); handlebarsRegisterHelpers();
const cache = handlebarsRenderDynamic._cache;
Handlebars.yomichan_cache = Handlebars.yomichan_cache || {}; let instance = cache.get(template);
let instance = Handlebars.yomichan_cache[template]; if (typeof instance === 'undefined') {
if (!instance) { instance = Handlebars.compile(template);
instance = Handlebars.yomichan_cache[template] = Handlebars.compile(template); cache.set(template, instance);
} }
return instance(data).trim(); return instance(data).trim();
} }
handlebarsRenderDynamic._cache = new Map();