Got next template in separate file section.htm:
<h3>${Name}</h3>
{{each Variables}}
{{tmpl($data) Type}}
${Type} | ${Name} |开发者_如何学编程 ${Value}
<br/>
{{/each}}
I need to render different templates (stored in htm files too) depending on Type. For example, for Type equal to "MultilineText" - MultilineText.htm should be used. Something like: {{tmpl($data) "MultilineText"}}
I already got MultilineText.htm loaded, compiled and cached.
Content of MultilineText.htm:
${Name}<textarea>${Value}</textarea>
But this code doesnt work :(
Please help.
Thanks.
And the answer is {{tmpl($value) $.template[$value.Type]}}
$.template[some_template_name] - with this u can choose what template will be rendered some_template_name - name of template.
Notice that template should be loaded and compiled with $.tmpl before and have some_template_name name.
I just ran into the same issue. You can add a call back to compare variables via a callback function.
Take a look at my question: Conditionals in jQuery templates
精彩评论