UNPKG

@signatu/common-lib

Version:

Common Javascript/Typescript library for Signatu

40 lines 1.28 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var Mustache = require("mustache"); var Template = /** @class */ (function () { function Template(template) { if (template === null || typeof template == 'undefined') { throw new Error("Template: constructor: template is undefined or null"); } this._template = template; } Object.defineProperty(Template.prototype, "template", { get: function () { return this._template; }, enumerable: true, configurable: true }); Template.prototype.render = function (data) { if (data === void 0) { data = {}; } return Mustache.render(this.template, data); }; Object.defineProperty(Template.prototype, "fields", { get: function () { var f = []; var mf = Mustache.parse(this.template); for (var i = 0; i < mf.length; i++) { var elem = mf[i]; if (elem[0] == 'name') { f.push(elem[1]); } } return f; }, enumerable: true, configurable: true }); return Template; }()); exports.Template = Template; //# sourceMappingURL=template.js.map