Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What are the pros/cons of using mustache with Backbone.js?

Tags:

I'm learning backbone.js for a Rails 3 application I'm working on. Backbone uses underscore which, I believe, has its own template engine built in.

I've read good things about mustache but was wondering if I should consider using it instead of the built in template engine of underscore?

What are your thoughts?

Thanks

like image 733
cbmeeks Avatar asked Jan 10 '12 16:01

cbmeeks


1 Answers

I am about halfway through my first enterprise level backbone app. I am currently using underscores built in templates because when I started the way I had learned was with underscore.. I don't necessarily have any problem with them. All of the templating solutions are pretty straight forward.

I have since looked at a few of the other solutions and am contemplating switching, but only because I think some of the other solutions look cleaner. Also some of the solutions have a tad bit more functionality.

I like mustache because of its shorter syntax. Looks cleaner. But I if I do switch I think I'm going to go with Handlebars.js.

Handlebars has the same short syntax, plus a ton of other features such as custom helper methods and setting object context inside your template. Check it out here. If I had known about handlebars at the beginning of my project I probably would have jumped on it for sure.

I wouldn't worry so much about adding another dependency as others have mentioned. Backbone apps done right will run lightning fast anyways. :D

If you have any other questions let me know. I've been really enjoying backbone so I'm trying to watch the tagged posts. But seriously. Handlebars looks legit.

EDIT:

I also meant to add that the documentation for handlebars looks way more legit than underscores...

like image 92
Mike Avatar answered Sep 27 '22 20:09

Mike