Instantly share code, notes, and snippets.

@mparke /base.js
Last active Dec 17, 2015

Embed
What would you like to do?
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