Created
April 17, 2012 01:04
-
-
Save mschwartz/2402679 to your computer and use it in GitHub Desktop.
This file contains 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
var smarty_cache = {} | |
function getCachedSmarty(key) { | |
// (key is whatever you use to lookup in the DB) | |
var template = smarty_cache[key]; | |
if (!template) { | |
template = SQL.getDataRow(query_to_get_template); | |
var compiled = smart.compile(template); | |
template = { | |
template: template, | |
compiled: compiled | |
}; | |
smarty_cache[key] = smarty_item; | |
} | |
return template.compiled; | |
} | |
function runSmarty(key, dict) { | |
var templateFn = getCachedSmarty(key); | |
return templateFn(dict); // this is the HTML output | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment