Skip to content
Umakant Patil edited this page Aug 11, 2017 · 3 revisions

Caching

Caching is used for subtemplates by default - any template loaded from {include} or {extends} through getTemplate function stored in the global internal cache, unless nocache flag is provided.

Also you can store a parsed tree of any template to speed up subsequent loads:

var cache = {};

var tpl;
if ('mytpl' in cache) {
    tpl = new jSmart;     //no template text in ctor
    tpl.tree = cache['mytpl'];
} else {
    tpl = new jSmart('...template text...');
    cache['mytpl'] = tpl.tree;    //store parse tree
}

tpl.fetch(...);
Clone this wiki locally