简体   繁体   中英

javascript/jquery templating suggestions

I am developing a large scale application highly dependent on javascript. Part of this will be displying information on screen. I am looking to display information on the ui and I am looking at using javascript templating to do such. I will be using the jquery framework.

Any suggestions or recommendations to javascript/jquery templating frameworks?

It's not jQuery based, but according to performance tests on jsperf.com, the doT.js templating framework is consistently the fastest JS templating framework. It has no dependencies, so you should be able to use it alongside jQuery.

这是一个有用的 jquery 模板库: http : //icanhazjs.com/另外,它的名字很有趣!

Only agree with GregL partially. The original test does not consider the time spent to eventually append the rendered html to the page.

You should also check out http://jsperf.com/dom-vs-innerhtml-based-templating/259
This test will include appending the rendered html text to the page.

You can compare it with http://jsperf.com/dom-vs-innerhtml-based-templating/257
The original test case. You will find out that the difference across template engines is not that significant. You do need to consider more about the usability of a template engine, unless you are going to simply render a chuck of html text without put it to the client browser.

Besides, in my opinion, a good template engine should greatly help you maintain the templates, help you write less to do more which is also the principle of jQuery.

doT.js is really great in performance, but I don't agree that it could help you code efficiently.

I am now working on an open source project to try to build a easy-to-use template engine. It can help you manage your templates in a tree-like structure, create template reference, define your own syntax, bind data to html dom.. please give it a try

http://jspopisno1.github.com/Beard

You can also have a read another question in stackoverflow

https://stackoverflow.com/questions/552934/what-javascript-templating-engine-do-you-recommend/8129492#8129492

Yes, i've used this John Resig's Microtemplating engine with great success in several projects. It's very simple, maintainable, and easy to use.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM