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:
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:
{{#if foo}}
<span>foo is set</span>
{{/if}
{{^if foo}}
<span>foo is not set</span>
{{/if}}
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With