【发布时间】:2015-09-07 13:17:30
【问题描述】:
我想做这样的事情:
<template name="list">
<ul>
{{#if items}}
{{#each items}}
<li>{{itemContents}}</li>
{{/each}}
{{else}}
<li class="placeholder">There are no items in this list.</li>
{{/if}}
<ul>
</template>
items 是 Meteor.cursor:
Template.list.items = function() {
return Items.find();
};
但是,上面的代码不起作用,因为即使没有项目,条件也会积极评估(这有点令人惊讶,因为 Handlebars 将 [] 评估为错误)。我尝试将条件更改为
{{#if items.count}}
然后我得到了一个神秘的错误
Unknown helper 'items'
那么,有没有办法在流星把手模板中编写这样的条件?
【问题讨论】:
标签: meteor handlebars.js