【发布时间】:2017-01-22 12:00:34
【问题描述】:
我希望能够检查一个列表是否为空,如果它不是打印一个块,但我不想为每个项目重复该块。我只想能够回显一次。
给出以下结构:
array(
"teasers" => array(
array("title"=>"Teaser Title 1"),
array("title"=>"Teaser Title 2")
)
);
{{# teasers }}
<div class="items-wrap">
<div class="items">
{{# . }}
<div class="item">
{{ title }}
</div>
{{/ . }}
</div>
</div>
{{/ teasers }}
我希望 items-wrap div 只打印一次,并为数组中的每个项目重复 item div。就像现在一样,items-wrap 对 teasers 数组中的每个项目重复一次。那么……有没有办法检查主数组是否为空,但不重复?
如果需要,目标是只打印一次items-wrap。
【问题讨论】:
标签: mustache.php