Search code examples
javascriptjqueryajaxtemplate-enginepure-js

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 (e.g.: 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.


Solution

  • 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.