Skip to content

Instantly share code, notes, and snippets.

@mparke
Last active December 17, 2015 20:29
Show Gist options
  • Save mparke/5667525 to your computer and use it in GitHub Desktop.
Save mparke/5667525 to your computer and use it in GitHub Desktop.
Backbone base view with Handlebars template rendering
App.Views.Base = Backbone.View.extend({
templateName: null,
render: function(){
var data;
if(this.templateName !== null){
if(this.model !== null){
data = this.model.toJSON()
}else{
data = {}
}
this.$el.html(Handlebars.templates[this.templateName](data))
}
return this.$el;
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment