Skip to content

Instantly share code, notes, and snippets.

@dagda1
Created June 29, 2011 12:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dagda1/1053720 to your computer and use it in GitHub Desktop.
Save dagda1/1053720 to your computer and use it in GitHub Desktop.
loadtemplates.js
loadTemplates: function() {
var templates = {};
$('*[type="text/x-js-template"]').map(function() {
var name = $(this).attr('name');
var source = $(this).html().replace('>', '>');
if(name.split('/')[1][0] == '_') { Handlebars.registerPartial(name.replace('/', ''), source) }
templates[name] = Handlebars.compile(source);
});
return templates;
},
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment