Precompile steering patterns

I am wondering what is the best way to save precompiled steering templates and include them in an HTML file.

Website: http://handlebarsjs.com/precompilation.html just advises calling

handlebars infile -f outfile

I put the template in a file and call the command. I got a JS file containing function1 function. How can I compile the second template now? The sample at http://jsperf.com/jquery-template-vs-handlebars contains several functions called program[1-9](...) I assume that they must be generated in some way. Good tip - store precompiled templates? I saw script attachment patterns or link tags in the HTML file and crawled them and through AJAX loading the templates and compiling them dynamically.

Best, Bernhard

+4
source share
3 answers

If you need several files, list them in the command like this:

 handlebars file1 file2 file3 -f outfile 

You want to store precompiled files for your production site, as it drastically reduces download time.

+8
source

You have to use

 handlebars /path/to/templates/*.handlebars -f /path/to/output/templates.js 
+6
source

The easiest way, provided that you want to save your templates with the html extension: handlebars html

i.e.: handlebars./-e html -f precompiled_templates.js

+2
source

Source: https://habr.com/ru/post/1413852/


All Articles