我正在使用{{#each}}在Meteor中迭代一个集合,我想知道我是否在最后一个元素中,就像我在AngularJS中使用ngRepeat和$ last一样.
例如,它可用于构建人类可读的枚举,如"我喜欢猫,狗和海豚":
Template.myTemplate.helpers({
likedAnimals: function(){return ['dogs','cats','dolphins'];}
});
<template name='myTemplate'>
I like
{{#each likedAnimals}}
{{#if !$first && !$last}}, {{/if}}
{{#if $last}} and {{/if}}
{{this}}
{{/each}}
</template>
Run Code Online (Sandbox Code Playgroud)
有没有办法检查Meteor中的这种情况?