smartmustache/dist/index.js

27 lines
1.2 KiB
JavaScript
Raw Permalink Normal View History

2016-11-20 16:41:26 +00:00
"use strict";
2017-02-25 22:40:15 +00:00
const handlebars = require("handlebars");
2016-11-20 16:41:26 +00:00
/**
* class Tlt allows templates to be used with different sets of data
*/
class Tlt {
/**
* constructor of class Tlt
*/
constructor(templateStringArg) {
2017-02-25 22:40:15 +00:00
this.template = handlebars.compile(templateStringArg);
2016-11-20 16:41:26 +00:00
}
/**
* returns template string with data applied
*/
applyData(data) {
2017-02-25 22:40:15 +00:00
return this.template(data);
2016-11-20 16:41:26 +00:00
}
/**
* set a new template string
*/
setTemplate(templateStringArg) {
2017-02-25 22:40:15 +00:00
this.template = handlebars.compile(templateStringArg);
2016-11-20 16:41:26 +00:00
}
}
exports.Tlt = Tlt;
2017-02-25 22:40:15 +00:00
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiO0FBQUEseUNBQXdDO0FBRXhDOztHQUVHO0FBQ0g7SUFHRTs7T0FFRztJQUNILFlBQVksaUJBQXlCO1FBQ25DLElBQUksQ0FBQyxRQUFRLEdBQUcsVUFBVSxDQUFDLE9BQU8sQ0FBQyxpQkFBaUIsQ0FBQyxDQUFBO0lBQ3ZELENBQUM7SUFFRDs7T0FFRztJQUNILFNBQVMsQ0FBQyxJQUFTO1FBQ2pCLE1BQU0sQ0FBQyxJQUFJLENBQUMsUUFBUSxDQUFDLElBQUksQ0FBQyxDQUFBO0lBQzVCLENBQUM7SUFFRDs7T0FFRztJQUNILFdBQVcsQ0FBQyxpQkFBeUI7UUFDbkMsSUFBSSxDQUFDLFFBQVEsR0FBRyxVQUFVLENBQUMsT0FBTyxDQUFDLGlCQUFpQixDQUFDLENBQUE7SUFDdkQsQ0FBQztDQUNGO0FBdkJELGtCQXVCQyJ9