Created
May 8, 2013 09:15
-
-
Save jackfranklin/5539270 to your computer and use it in GitHub Desktop.
Really simple template loaded with jQuery.
This file contains hidden or 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 Template = function(opts) { | |
this.name = opts.name; | |
}; | |
Template.prototype.load = function(cb) { | |
var self = this; | |
cb = cb || function() {}; | |
var req = $.ajax({ | |
url: "/templates/" + this.name + ".handlebars" | |
}); | |
req.fail(function() { | |
throw("Could not load the template"); | |
}); | |
req.done(function(data) { | |
cb.call(self, data); | |
}); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
looks neat. defo gonna use it from now on :D