Created
July 15, 2014 13:49
-
-
Save benhowdle89/929b567105e1c663793c to your computer and use it in GitHub Desktop.
CommonJS Backbone inheritence
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
var Backbone = require('backbone'); | |
var $ = require('jquery'); | |
var Handlebars = require('handlebars'); | |
var HandlebarsHelpers = require('base/utils/template-helpers'); | |
var templateCache = require('base/utils/template-cache'); | |
module.exports = Backbone.View.extend({ | |
initialize: function(options) { | |
this.templates = templateCache.get(); | |
}, | |
render: function() { | |
var template = Handlebars.compile(this.templates[this.template]), | |
templateData = $.extend({}, this.templateData); | |
this.$el.html(template(templateData)); | |
if (this.renderAfter) { | |
setTimeout(this.renderAfter.bind(this), 0); | |
} | |
return this; | |
} | |
}); |
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
module.exports = { | |
set: function(obj){ | |
this.templates = obj; | |
}, | |
get: function(){ | |
return this.templates; | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment