-
-
Save nzifnab/960135 to your computer and use it in GitHub Desktop.
jquery tmpl templating function for use with jammit
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
// It's more advisable to store the compiled version of the jQuery template in JST, | |
// And then use a separate function that renders on a per-use basis from that pre-compiled template. | |
function jqueryCacheTemplate(templateString){ | |
return $.template(null, templateString); | |
} | |
function jqueryTemplate(name){ | |
return $.tmpl(JST[name], arguments[0], arguments[1]); | |
} | |
// And then, in assets.yml, you can set "template_function" to "jqueryCacheTemplate" | |
// And to use a template, instead of JST['my_template](data), you should use jqueryTemplate('my_template', data) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment