-
-
Save mxriverlynn/2232998 to your computer and use it in GitHub Desktop.
template cache
This file contains hidden or 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
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; | |
} | |
} |
This file contains hidden or 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
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; | |
} | |
} |
the "var" shouldn't be there on line 7. my intention was to re-use the same template variable (which this does... its just bad form)
fixed
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
is 'template' re-declared inside the if for a reason?