I am writing a lot of web applications that requires a lot of dynamic content that is replaced according to various ajax request to the PHP+mySQL backend that is able to respond all data as JSON. This could be something like quizzes, polls or it could also be more advanced applications that requires more updates of the DOM. The point is that the integration with the HTML (wich is coded by a third part) is as easy as possible.
Since this are many small applications and not a big site, I am looking for a library that helps me get the job done fast and easy to customize later on. I don't know the best way of doing this but know that there are various libraries out there that does what I need (and a lot more).
Required features:
- Lightweight
- Easy to update the HTML structure (even for HTML-only coders)
- Compatible with jQuery
- Works with all modern browsers including Chrome, Firefox, Safari and IE7+
- Works with all mobile browsers including Android, iOS and Windows Mobile
Try JUST. It has similar syntax with EJS but more it powerful. It have very useful features like inheritance, partials and block redefenitions. It work on client and server (node.js) side.
I would try mustache. I've used it in the past and it's pretty good; fast and intuitive.
I would try Distal.
You said your HTML is coded by a third party so you would want minimal changes during integration. With distal you add stuff to the existing HTML and don't need to move things around.
The syntax is HTML based so it's suitable for HTML only coders.
Mustache is pretty solid, but I found it to be a little too hardline about the "logicless template" thing. For example, it doesn't offer a lot of small niceties you'd hope for in a templating system, like an "else" statement. You have to do dumb stuff like this all the time:
Instead, I'd recommend Handlebars which is built on top of Mustache, but adds some nice features like custom helpers and better context-switching support.