Skip to content

Instantly share code, notes, and snippets.

@mxriverlynn
Created March 29, 2012 03:32
Show Gist options
  • Save mxriverlynn/2232998 to your computer and use it in GitHub Desktop.
Save mxriverlynn/2232998 to your computer and use it in GitHub Desktop.
template cache
TemplateCache = {
get: function(selector){
if (!this.templates){ this.templates = {}; }
var template = this.templates[selector];
if (!template){
var template = $(selector).html();
this.templates[selector] = template;
}
return template;
}
}
TemplateCache = {
get: function(selector){
if (!this.templates){ this.templates = {}; }
var template = this.templates[selector];
if (!template){
template = $(selector).html();
// precompile the template, for underscore.js templates
template = _.template(template);
this.templates[selector] = template;
}
return template;
}
}
@mxriverlynn
Copy link
Author

fixed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment