因此,关于这个主题有很多较旧的问题,它们指出了许多可用的选项。例如,以下两个问题是该主题中回答最多的问题:
JavaScript 支持哪些好的模板语言? https://stackoverflow.com/questions/128949/what-good-template-language-is-supported-in-javascript
jQuery 模板引擎 https://stackoverflow.com/questions/170168/jquery-templating-engines
这两个问题的大部分答案都是 2008 年的。
然而在过去一年左右的时间里,JavaScript 的格局已经发生了很大的变化。例如,.NET JQuery 扩展最近被添加为官方 JQuery 插件。
在当前的模板引擎中,哪一个是最好使用的?以下是我所知道的一些选项:
- JQuery-tmpl
- https://github.com/jquery/jquery-tmpl https://github.com/jquery/jquery-tmpl
- http://blog.jquery.com/2010/10/04/new-official-jquery-plugins-provide-templated-data-linking-and-globalization/ http://blog.jquery.com/2010/10/04/new-official-jquery-plugins-provide-templating-data-linking-and-globalization/
- http://weblogs.asp.net/scottgu/archive/2010/10/04/jquery-templates-data-link-and-globalization-accepted-as-official-jquery-plugins.aspx http://weblogs.asp.net/scottgu/archive/2010/10/04/jquery-templates-data-link-and-globalization-accepted-as-official-jquery-plugins.aspx
- http://www.borismoore.com/2010/10/jquery-templates-is-now-official-jquery.html http://www.borismoore.com/2010/10/jquery-templates-is-now-official-jquery.html
- (以前是 NJE 项目)
- John Resig's Micro-templates
- http://ejohn.org/blog/javascript-micro-template/ http://ejohn.org/blog/javascript-micro-templating/
- 包含在 underscore.js 中
- JTemplates
- http://jtemplates.tpython.com/ http://jtemplates.tpython.com/
- http://plugins.jquery.com/project/jTemplates http://plugins.jquery.com/project/jTemplates
- PURE (Pure Unobtrusive Rendering Engine)
- http://beebole.com/pure/ http://beebole.com/pure/
- ASP.NET Ajax Templates
- http://msdn.microsoft.com/en-us/magazine/cc546561.aspx http://msdn.microsoft.com/en-us/magazine/cc546561.aspx
- jQuery Smarty
- https://github.com/balupton/jquery-smarty https://github.com/balupton/jquery-smarty
考虑到所有这些不同的选择,哪一个可能是最好的选择?
我试图在 Resig 的 Microtemplates 和 JQuery-tmpl 之间做出选择,但我不知道两者中哪一个更好,或者是否有比它们更好的选择。
任何熟悉许多可用选项的人都可以就此事提供一些建议吗?
不应考虑 ASP.NET Ajax 库的 DataView。它在发布之前已被弃用,取而代之的是 jQuery 模板。
我已经使用 jTemplates 几年了,发现它足够可靠。然而,随着 jQuery 模板计划包含在 jQuery 1.5 核心中,采用外部依赖项来重新实现已包含在核心库中的内容是没有意义的。假设您正在使用 jQuery,仅此一点就足以支持 jQuery 模板。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)