Created
July 11, 2011 17:18
-
-
Save cmorss/1076315 to your computer and use it in GitHub Desktop.
Jammit Handlebar Template funciton
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
Handlebars.template = function(templateString) { | |
return function () { | |
if (arguments.length < 1) { | |
// With no arguments, return the raw template -- useful for rendering | |
// partials. | |
return templateString; | |
} else { | |
Handlebars.templates = Handlebars.templates || {} | |
Handlebars.templates[templateString] = Handlebars.templates[templateString] || Handlebars.compile(templateString); | |
return Handlebars.templates[templateString](arguments[0], arguments[1]); | |
} | |
}; | |
}; |
Thanks rx, I fixed the gist in case anyone else runs across it.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I forked to get this working. Here is the fork: git://gist.github.com/1118201.git