My template is this one below, and I'd like to use a list of html as parameter
{template .myTemplate}
{@param title: string}
{@param? listHtml: list<html>}
<ul>
{foreach $item in $listHtml}
<li>
<a>{$item}</a>
</li>
{/foreach}
</ul>
{/template}
My problem is that I don't know how to pass a list of html elements as parameter when I call the template.
{call desktop.common.myTemplate }
{param title: 'Contact us' /}
{param listHtml kind="html" }
????
{/param}
{/call}
How about breaking out a helper template:
{template .myTemplate}
{@param title: string}
{@param? items: html}
<ul>
{$items}
</ul>
{/template}
{template .myItemTemplate}
{@param content: html}
<li>
<a>{$content}</a>
</li>
{/template}
Which pushes iteration to the caller, where I assume the list of items is static:
{call desktop.common.myTemplate }
{param title: 'Contact us' /}
{param items kind="html"}
{call desktop.common.myItemTemplate}
{param content kind="html"}foo{/param}
{/call}
{call desktop.common.myItemTemplate}
{param content kind="html"}bar{/param}
{/call}
{/param}
{/call}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.