标签:
定义一个function {function name=menu level=0} <ul class="level{$level}"> {foreach $data as $entry} {if is_array($entry)} <li>{$entry@key}</li> {call name=menu data=$entry level=$level+1} {else} <li>{$entry}</li> {/if} {/foreach} </ul> {/function} 创建一个测试数组 {$menu = [‘item1‘,‘item2‘,‘item3‘ => [‘item3-1‘,‘item3-2‘,‘item3-3‘ => [‘item3-3-1‘,‘item3-3-2‘]],‘item4‘]} 运行call {call name=menu data=$menu} {call menu data=$menu} {* short-hand *}
输出
* item1 * item2 * item3 o item3-1 o item3-2 o item3-3 + item3-3-1 + item3-3-2 * item4
标签:
原文地址:http://www.cnblogs.com/whlives/p/4430596.html