简体   繁体   中英

jQuery: Templating data

I have a unique situation where I'm building a site that will call data via AJAX and load it into "containers" (basically just divs styled and arranged according to elements retrieved from the AJAX callback).

I'm not sure how many of these unique container types will be created (styled and rendered) when all is said and done, so I'm looking for a solution that will allow me to store containers in a separate file(s), load them dynamically as they are needed, populate the content, and rendered them on page.

I'm not sure if I should write my own loading/template solution or use an existing JavaScript template engine (eg: Pure).

The reason I'm hesitant to use an existing JavaScript template solution is they all seem focused on binding and looping on existing page elements, whereas I'm more concerned with the ability to load-up and binding to dynamic content.

You might want to give a try, it's the most powerful jQuery templating engine as it let's you use scripting inside your templates. ,它是功能最强大的jQuery模板引擎,它使您可以在模板中使用脚本。

Go check it out, it'll suit your needs, I promise.

http://aefxx.com/jquery-plugins/jqote

After starting with JST, we moved to EJS:

http://embeddedjs.com/

It's more powerful, syntactically simpler, and you can put your templates in different files.

The website is pretty nice too.

我正计划在将来的项目中使用jTemplates ,该项目将需要执行以下操作,它非常快并且具有一个不错的jQuery插件

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