您推荐哪些 Javascript 模板引擎?
我想了解一下您对javascript模板引擎的看法,您认为哪一个在性能方面更好?
我发现了一些人们进行基准测试的链接:
http://jsperf.com/jquery-template-table-performance/15
http://jsperf.com/jquery-template-table-performance/8
<一个href="http://www.viget.com/extend/benchmarking-javascript-templat-libraries/">http://www.viget.com/extend/benchmarking-javascript-templat-libraries/
I would like to know your opinion about javascript template engine, which one you think is better in terms of performance?
I found some links where people do benchmarking:
http://jsperf.com/jquery-template-table-performance/15
http://jsperf.com/jquery-template-table-performance/8
http://www.viget.com/extend/benchmarking-javascript-templating-libraries/
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
Template-Engine-Chooser! - 帮助选择正确模板的工具项目的模板引擎。
Template-Engine-Chooser! - Tool to help select the right template engine for a project.
就性能而言,我发现这不是模板引擎本身的问题,而是如果有可能预编译模板的话。无论如何,将所有 JavaScript 源文件连接并缩小为一个文件以用于生产模式是一种很好的做法,因此预编译模板的步骤基本上也是相同的。
我已经使用 jQuery 模板和 Mustache 进行客户端模板,但我最喜欢的仍然是 EJS 它的执行速度总是比我迄今为止尝试过的任何其他方法都要快得多,尤其是在生产模式下(尽可能编译为本机字符串连接,并且只需要一次 DOM 访问即可实际插入渲染的视图)。它是 JavaScriptMVC 框架的一部分,并且与 StealJS 作为依赖项管理器,它已经为您将所有模板编译为生产环境(View Engine 还支持 Micro、Mustache 和 jQuery 模板)。
In terms of performance I found that it is not the templating engine itself but more if there is the possibility to precompile the templates. It is a good practice to concatenate and minify all your JavaScript source files into one file for production mode anyway, so it is basically the same step to precompile the templates, too.
I've used jQuery template and Mustache for client side templating, but my favorite is still EJS which always peformed a lot faster than anything else I tried so far, especially in production mode (compiles to native string concatenation whenever possible and needs only one DOM access to actually insert the rendered view). It is part of the JavaScriptMVC framework and when using it with StealJS as the dependency manager it does all the template compiling into production for you already (the View Engine also supports Micro, Mustache and jQuery template).
可能是 PURE — 它允许使用模板将 JSON 转换为 HTML由现有的 html 制成,而不是由具有特殊语法的单独模板制成。
来自 PURE 的网站:
理解的最佳方法是查看这个库实际上做了什么:(来自官方演示)

所有演示均此处
May be PURE — it allows to transform JSON into HTML with templates made from your existed html, not from separate template with special syntax.
From the PURE's site:
The best way to understand is to see what this library actually do: (from official demo)

All the demos are here
LinkedIn 与dust.js 一起使用
http://akdubya.github.com/dustjs/
LinkedIn went with dust.js
http://akdubya.github.com/dustjs/
选择具有您认为最有吸引力的 API 和语法的模板语言。如果您遇到性能问题,那么您可以考虑替代方案。
除非您正在构建具有数千行的表,否则您可能不会注意到差异。
我个人使用 Google 的Closure Templates。我选择它主要是因为它也有Java实现。我从来没有做过基准测试。
Pick the template language that has an api and syntax you find most appealing. If you run in to performance problems, then you can look at alternatives.
Unless you are constructing tables with thousands of rows, you probably won't notice a difference.
Personally I use Google's Closure Templates. I chose it mainly because it also has a Java implementation. I have never done benchmarks.