Skip to content

Instantly share code, notes, and snippets.

@TexRx
Forked from jackfranklin/template.js
Created May 8, 2013 09:28
Show Gist options
  • Select an option

  • Save TexRx/5539344 to your computer and use it in GitHub Desktop.

Select an option

Save TexRx/5539344 to your computer and use it in GitHub Desktop.
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