Skip to content

Instantly share code, notes, and snippets.

@charliewilson
Created April 17, 2012 18:27
Show Gist options
  • Save charliewilson/2408008 to your computer and use it in GitHub Desktop.
Save charliewilson/2408008 to your computer and use it in GitHub Desktop.
A tiny jQuery plugin used in conjunction with mustache.js to interpret mustache code at runtime on specific elements.
// Usage:
//
// $("body").mustache(view);
//
// where 'view' is a mustache view object.
(function( $ ){
$.fn.mustache = function(viewobj) {
var elementtext = this.html();
var output = Mustache.render(elementtext, viewobj);
this.html(output);
return this;
};
})( jQuery );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment