I am learning Backbone/Handlebars/Require. I have looked all over online and on SO – are there any tutorials or websites that you can direct me to that would provide helpful information for using using handlebars instead of underscore?
I am learning Backbone/Handlebars/Require. I have looked all over online and on SO –
Share
Using
handlebars.jsinstead ofunderscoretemplating is pretty straightforward. Check out this example:https://cdnjs.com/libraries/backbone.js/tutorials/what-is-a-view
(scroll to the “Loading a Template” section)
Basically, the convention in backbone is to build your html in a render function. The use of templating engine is left completely up to you (which I like about Backbone). So you’d just change it to:
Since you’re using
require.js, you can makeHandlebarsa dependency at the top of your module. I’m pretty new to this, but it sounds like the learning to focus on would beBackbone.jspatterns andrequire.jsusage.