UNPKG

atpl

Version:

A complete and fast template engine fully compatible with twig and similar to jinja with zero dependencies.

23 lines (22 loc) 818 B
"use strict"; var MemoryTemplateProvider = (function () { function MemoryTemplateProvider() { this.registry = {}; this.registryCached = {}; } MemoryTemplateProvider.prototype.add = function (path, data) { this.registry[path] = data; }; MemoryTemplateProvider.prototype.getSync = function (path, cache) { if (!cache) delete this.registryCached[path]; if (this.registryCached[path] === undefined) this.registryCached[path] = this.registry[path]; var data = this.registryCached[path]; if (data === undefined) throw (new Error("Can't find key '" + path + "'")); return data; }; return MemoryTemplateProvider; }()); exports.MemoryTemplateProvider = MemoryTemplateProvider;