Created
November 30, 2012 10:04
-
-
Save khepin/4174906 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Useful piece of code.
Is this open source? Under which terms may this be used?