I would like to choose a template engine for the Backbone.js
framework I'll use inside my MVC application.
I've read Backbone.js is compatible with Mustache.js
, Handlebars.js
and Underscore.js
by default, does exist some important difference between these template engines or they do almost the same thing?
Also, does exists other template engines compatible with Backbone.js
should be seriously considered?
Handlebars. js is an extension to the Mustache templating language created by Chris Wanstrath. Handlebars. js and Mustache are both logicless templating languages that keep the view and the code separated like we all know they should be; Mustache: Logic-less templates.
Mustache has interpreters in many languages, while Handlebars is Javascript only.
Mustache can be used for HTML, config files, and source code. It works by expanding tags in a template using values provided in a hash or object. You can use Mustache to render templates anywhere include client side and server side environments.
Mustache and Handlebars are what are known as "logic-less template engines." They force developers not to include any overly complex logic in the view, only the most basic control structures needed to output data, keeping the HTML (or other content) clean. This also means they are completely language agnostic; you should be able to use them with any programming/scripting language with little trouble.
Underscore however is different. It's a JavaScript library in itself, like Prototype or jQuery, and comes with it's own templating engine. The templates have access to any method or helpers within the library, meaning the templates are strictly tied to JavaScript and house a lot more of the logic.
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