预编译手柄模板 [英] precompile handlebar templates

查看:87
本文介绍了预编译手柄模板的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道保存预编译的句柄模板并将它们包含在HTML文件中的最佳方法是什么。



该站点: http://handlebarsjs.com/precompilation.html 只是建议您致电


handlebars infile -f outfile

我把一个模板放到一个文件中并调用命令。我有一个包含函数 program1 的JS文件。现在我将如何编译第二个模板? http://jsperf.com/jquery-template-vs-handlebars 中的示例包含多个函数名为程序[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

handlebars infile -f outfile

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.

这篇关于预编译手柄模板的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆