您推荐哪些 Javascript 模板引擎?

发布于 2024-12-10 12:47:53 字数 506 浏览 3 评论 0原文

我想了解一下您对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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

十秒萌定你 2024-12-17 12:47:53

Template-Engine-Chooser! - 帮助选择正确模板的工具项目的模板引擎。

Template-Engine-Chooser! - Tool to help select the right template engine for a project.

奢望 2024-12-17 12:47:53

就性能而言,我发现这不是模板引擎本身的问题,而是如果有可能预编译模板的话。无论如何,将所有 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).

为人所爱 2024-12-17 12:47:53

可能是 PURE — 它允许使用模板将 JSON 转换为 HTML由现有的 html 制成,而不是由具有特殊语法的单独模板制成。

来自 PURE 的网站:

简单且超快速的模板工具
从 JSON 数据生成 HTML

表示(HTML)和逻辑(JS)
保持完全分离

独立工作或与dojo、DomAssistant、Ext JS、
jQuery、Mootools、Prototype、Sizzle 和 Sly

理解的最佳方法是查看这个库实际上做了什么(来自官方演示)
纯模板引擎演示

所有演示均此处

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:

Simple and ultra-fast templating tool
to generate HTML from JSON data

The representation (HTML) and the logic (JS)
remain totally separated

Works standalone or with dojo, DomAssistant, Ext JS,
jQuery, Mootools, Prototype, Sizzle and Sly

The best way to understand is to see what this library actually do: (from official demo)
pure template engine demonstration

All the demos are here

绝對不後悔。 2024-12-17 12:47:53

LinkedIn 与dust.js 一起使用
http://akdubya.github.com/dustjs/

LinkedIn went with dust.js
http://akdubya.github.com/dustjs/

述情 2024-12-17 12:47:53

选择具有您认为最有吸引力的 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文