27 lines
732 B
JavaScript
27 lines
732 B
JavaScript
class VTepLTemplate {
|
|
constructor(name, content, core) {
|
|
this.name = name;
|
|
this.tpl = content;
|
|
this.parser = new VTpeLParser(name, content);
|
|
this.core = core;
|
|
}
|
|
|
|
async render(data = {}) {
|
|
return await new VTepLInterpreter(this.parser, this.core).render(data);
|
|
}
|
|
|
|
parseContent(cache) {
|
|
if (cache) {
|
|
let storage = localStorage.getItem("vtepl-" + this.name);
|
|
if (storage) {
|
|
this.parser.parsed = JSON.parse(storage);
|
|
return;
|
|
}
|
|
}
|
|
this.parser.tokenize();
|
|
if (cache) {
|
|
localStorage.setItem("vtepl-" + this.name, JSON.stringify(this.parser.parsed));
|
|
}
|
|
}
|
|
}
|