Skip to content

Instantly share code, notes, and snippets.

@krambuhl
Last active December 14, 2015 19:49
Show Gist options
  • Save krambuhl/5139824 to your computer and use it in GitHub Desktop.
Save krambuhl/5139824 to your computer and use it in GitHub Desktop.
Mustache/jQuery wrapper: Loads a mustache template via ajax: onsuccess, mustache template is rendered (on all matched contexts). if callback is defined, it will be called.
var renderTemplate = function(context, source, data, callback) {
$.get(source, function(template){
$(context).html($.mustache(template, data));
if (typeof callback === "function")
callback.call(this, context);
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment