It is possible to precompile your Handlebars template (the result is a JavaScript function), and then include the compiled templates via a script element.
Advantages of precompiling the templates include:
So here's an example where I've compiled the course list template into courseslist.js. Now there's no compile step, just a reference to Handlebars.templates.courseslist to access the template function. Note too that we are using the "runtime" version of the Handlebars library - handlebars.runtime.min.js
Note the command to compile the template looked like:
$ handlebars.js courseslist -f courseslist.jswhere courseslist is the source template, and courseslist.js is the generated compiled JS file
Copyright © David Heitmeyer