jQuery tmpl plugin - Conditional templates? -
i'm generating list using jquery tmpl plugin:
<script id="maintemplate" type="text/x-jquery-tmpl"> <li> <a class="page" href="#" rel="${link}" >${description}</a> </li> </script>
is @ possible have things conditionally processed using jquery templates? tried:
<script id="maintemplate" type="text/x-jquery-tmpl"> <li> {{if ${type} == "intlink" }} <a class="page" href="#" rel="${link}" >${description}</a> {{/if}} </li> </script>
but didn't work. want able conditionally have different template output depending on data being passed (via json).
there no need wrap type within if markup. should work
<script id="maintemplate" type="text/x-jquery-tmpl"> <li> {{if type == "intlink" }} <a class="page" href="#" rel="${link}" >${description}</a> {{/if}} </li> </script>
assuming data contains {"type": "intlink"}.
Comments
Post a Comment