Most of the templating engines I’ve seen will return a JS function when you pass the JavaScript template without context. You can then save that JS function and effectively prevent from having to parse the template tokens every time you want to create the same template with different context.
However, I can’t seem to find a way to do this with mustache.js, which means for every call to the renderer with the same template, the exact same token parsing code is being run with the exact same results each time with the only difference being the context values.
Does anyway know if there’s a way to extract a pre-compiled JavaScript template function from out of mustache.js?
well caching in mustache is not necessary the templating engine does not benefit from caching. There was a comparison done between the various libraries and which library stands to gain from caching. here is the link: http://www.viget.com/extend/benchmarking-javascript-templating-libraries/
I hope I got your question right, caching the compiled template right?