问题描述
我想知道保存预编译的句柄模板并将它们包含在HTML文件中的最佳方法是什么。
该站点:只是建议您致电
我把一个模板放到一个文件中并调用命令。我有一个包含函数 program1 的JS文件。现在我将如何编译第二个模板? 中的示例包含多个函数名为程序[1-9](...)
我假设它们必须以某种方式生成。
是否存储预编译模板的好建议?
我在HTML文件中看到了嵌入脚本或链接标签的样本,并通过AJAX遍历这些样本并加载模板并动态编译。
Best,
Bernhard
如果您想要多个文件,请像命令一样列出它们。 $ b
handlebars file1 file2 file3 -f outfile
您希望为您的生产站点存储预编译的文件,因为它大大缩短了加载时间。
I'm wondering what's the best way to save precompiled handlebar templates and include them in an HTML file.
The site: http://handlebarsjs.com/precompilation.html simply advises to call
I put a template in a file and called the command. I got a JS file containing a function program1 How would I now compile a second template? The sample at http://jsperf.com/jquery-template-vs-handlebars contains multiple functions named program[1-9](...)
I assume they somehow must be generated.Is it good advice to store precompiled templates at all?I saw samples embedding script or link tags in an HTML file and traversing these and via AJAX loading the templates and compiling them dynamically.
Best,Bernhard
If you want multiple files, list them in the command like so
handlebars file1 file2 file3 -f outfile
You DO want to store precompiled files for your production site as it drastically cuts down on load time.
这篇关于预编译手柄模板的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!