php mustache条件值,如Handlebar块助手

php mustache条件值,如Handlebar块助手,php,mustache,handlebars.js,mustache.php,Php,Mustache,Handlebars.js,Mustache.php,在Handlebar中,可以创建条件,例如: {{#if isActive}} <img src="star.gif" alt="Active"> {{/if}} 留胡子一定有办法,对吧?不是难看,是胡子。每个实现都有自己的方法来避免这种功能不足,而且看起来您可以使用PHP数组的.count属性,如{{{{list.count}}..{{/list.count}:{{{{list.count}中的{code>ArrayIterator包装数组时才有效。你可以用一个{{{#lis

在Handlebar中,可以创建条件,例如:

{{#if isActive}}
  <img src="star.gif" alt="Active">
{{/if}}

留胡子一定有办法,对吧?

不是难看,是胡子。每个实现都有自己的方法来避免这种功能不足,而且看起来您可以使用PHP数组的.count属性,如{{{{list.count}}
    ..
{{/list.count}:
{{{{list.count}
中的{code>ArrayIterator包装数组时才有效。你可以用一个
{{{#list.0}}
节标记来伪装它,但在我看来,这比添加额外的值要难看得多。
.count
为我提供了一个
新的ArrayObject
。谢谢
{{#hasList }}
<ul>
{{# list }}
    <li>{{ title }}</li>
{{/ list }}
</ul>
{{/hasList }}