Skip to content

Instantly share code, notes, and snippets.

@ianb
Created May 18, 2010 20:47
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 ianb/405517 to your computer and use it in GitHub Desktop.
Save ianb/405517 to your computer and use it in GitHub Desktop.
templateDirectives = {
'page-main': {
...
},
'page-view': {
...
}
};
templates = {};
$('#templates > div').each(function (index) {
var name = this.className.split(' ')[0];
var directives = templateDirectives[name];
var template = $(this).compile(directives);
templates[name] = template;
});
function renderPage(name, data) {
var template = templates[name];
$('#body').html(template(data));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment