开发者

litteral ${} and {{ }} in jquery templates

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">
        $&#123;test&#125;
</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/

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜