Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save goliatone/5236905 to your computer and use it in GitHub Desktop.
Save goliatone/5236905 to your computer and use it in GitHub Desktop.
(function ($) {
var compiled = {};
$.fn.handlebars = function (template, data) {
if (template instanceof jQuery) {
template = $("<div />").append($(template).clone()).html();
}
compiled[template] = Handlebars.compile(template);
this.html(compiled[template](data));
};
})(jQuery);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment