Using JQuery templates, what is the best way to output literal ${}
and {{ }}
strings?
I need this because I would like to write templates that themselve开发者_高级运维s generate other templates.
I am not sure of your exact needs, but if you are, for whatever reason, not able to use nested templates, then how about as a workaround either something like:
<script id="options" type="text/html">
${test}
</script>
or
<script id="options" type="text/html">
${writeVariable('test')}
</script>
with writeVariable (and other helpers or a more generic/advanced version of this one) defined elsewhere:
function writeVariable(varName) {
return "${" + varName + "}";
}
I did see reference in another post to a {#literal} tag, but I don't see that available anywhere in recent jquery.tmpl.js code.
I don't think you want to write ${} and {{}} as literals. I think you want to use nested templates: http://api.jquery.com/template-tag-tmpl/
精彩评论