Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between Mustache.js, Handlebars.js and Underscore.js? [closed]

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?

like image 335
vitto Avatar asked Mar 21 '13 22:03

vitto


People also ask

How Handlebars js is different from Mustache js?

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.

How Handlebars js is different from Mustache js Mcq?

Mustache has interpreters in many languages, while Handlebars is Javascript only.

What is Mustache js used for?

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.


1 Answers

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.

like image 198
Adam Avatar answered Oct 10 '22 23:10

Adam