推荐用于JQuery的JavaScript HTML模板库? [英] Recommended JavaScript HTML template library for JQuery?
问题描述
关于哪个HTML模板库与JQuery相处得好的任何建议?谷歌搜索引起了相当多的图书馆,但我不确定是否有一个经过充分认可的图书馆经得起时间的考验。
Any suggestions on which HTML template library would go well with JQuery? Googling turns up quite a number of libraries but I'm not sure whether there is a well recognized library that would stand the test of time.
推荐答案
嗯,坦白说,客户端的模板现在非常热,但是相当丛林。
Well, to be frank, client-side templating is very hot nowadays, but quite a jungle.
最受欢迎的是,我相信:
the most popular are, I believe:
- pure: It use only js, not his own "syntax"
- mustache: quite stable and nice I heard.
- jqote2: extremely fast according to jsperfs
- jquery templates (deprecated):
有很多其他人,但是你必须测试它们才能看到适合自己的东西,以及最好的项目风格。
there are plenty others, but you have to test them to see what suits you, and your project style, best.
就个人而言,我很难添加新的语法和设置逻辑(混合逻辑和模板,hello ?? )和wen纯粹的js。我的每个模板都存储在自己的html文件(./usersTable.row.html)中。我只在ajaxing内容时使用模板,并且我有几个逻辑js文件,一个用于表,一个用于div,一个用于列表。甚至没有一个选择的选项(我使用另一种方法)。
Personally, I have a hard time with adding a new syntax and set of logic (mixing logic and template, hello??), and went pure js. Every single one of my templates is stored in it's own html file (./usersTable.row.html). I use templates only when ajaxing content, and I have few "logic" js files, one for tables, one for div, one for lists. and not even one for select's options (where i use another method).
每当我尝试做一些更复杂的事情时,我发现代码不太清楚并且采取了我有更多时间来稳定,而不是采用旧的方式。在我看来,模板中的逻辑是完全没有意义的,添加它自己的语法只会增加非常难以追踪的错误。
Each time I tried to do something more complex, I found out the code was less clear and taking me more time to stabilize than doing it the "old" way. Logic in the template is an utter non-sense in my opinion, and adding it's own syntax adds only very-hard-to-trace bugs.
这篇关于推荐用于JQuery的JavaScript HTML模板库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!