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) {
handlebarsRegisterHelpers();
Handlebars.yomichan_cache = Handlebars.yomichan_cache || {};
let instance = Handlebars.yomichan_cache[template];
if (!instance) {
instance = Handlebars.yomichan_cache[template] = Handlebars.compile(template);
const cache = handlebarsRenderDynamic._cache;
let instance = cache.get(template);
if (typeof instance === 'undefined') {
instance = Handlebars.compile(template);
cache.set(template, instance);
}
return instance(data).trim();
}
handlebarsRenderDynamic._cache = new Map();