backbone.js - Using Handlebars with Backbone -



backbone.js - Using Handlebars with Backbone -

i learning backbone/handlebars/require. have looked on online , on - there tutorials or websites can direct me provide helpful info using using handlebars instead of underscore?

using handlebars.js instead of underscore templating pretty straightforward. check out example:

http://backbonetutorials.com/what-is-a-view/ (scroll "loading template" section)

searchview = backbone.view.extend({ initialize: function(){ this.render(); }, render: function(){ // compile template using underscore var template = _.template( $("#search_template").html(), {} ); // load compiled html backbone "el" this.el.html( template ); } });

basically, convention in backbone build html in render function. utilize of templating engine left (which backbone). you'd alter to...

searchview = backbone.view.extend({ initialize: function(){ this.render(); }, render: function(){ // compile template using handlebars var template = handlebars.compile( $("#search_template").html() ); // load compiled html backbone "el" this.el.html( template ); } });

since you're using require.js, can create handlebars dependency @ top of module. i'm pretty new this, sounds learning focus on backbone.js patterns , require.js usage.

backbone.js requirejs handlebars.js

Comments

Popular posts from this blog

How do I check if an insert was successful with MySQLdb in Python? -

delphi - blogger via idHTTP : error 400 bad request -

postgresql - ERROR: operator is not unique: unknown + unknown -