Last active
December 17, 2015 20:29
-
-
Save mparke/5667525 to your computer and use it in GitHub Desktop.
Backbone base view with Handlebars template rendering
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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