Skip to content

Instantly share code, notes, and snippets.

@cmorss
Created July 11, 2011 17:18
Show Gist options
  • Save cmorss/1076315 to your computer and use it in GitHub Desktop.
Save cmorss/1076315 to your computer and use it in GitHub Desktop.
Jammit Handlebar Template funciton
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]);
}
};
};
@rx
Copy link

rx commented Aug 22, 2011

I forked to get this working. Here is the fork: git://gist.github.com/1118201.git

@cmorss
Copy link
Author

cmorss commented Aug 22, 2011

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