Skip to content

Instantly share code, notes, and snippets.

@khepin
Created November 30, 2012 10:04
Show Gist options
  • Save khepin/4174906 to your computer and use it in GitHub Desktop.
Save khepin/4174906 to your computer and use it in GitHub Desktop.
/**
* Allow underscore use of partials
*/
var underscorePartials = (function(){
var partialCache = {};
var mixin = {
declarePartial: function(name, template) {
partialCache[name] = _.template(template);
},
partial: function(name, data) {
return partialCache[name](data)
}
};
return mixin;
})();
_.mixin(underscorePartials)
@mef
Copy link

mef commented Jan 18, 2015

Useful piece of code.

Is this open source? Under which terms may this be used?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment