【发布时间】:2017-07-17 23:54:59
【问题描述】:
这就是我所拥有的:
Template.publicnewsjson.helpers({
news:function(){
return news.find({}, { sort: {date:-1} } );
},
newscount:function(){
return news.find().count();
}
});
<template name="publicnewsjson">
<pre>
{{#each news}}
{
Title:{{title}}
Date:{{friendlydate this.date}}
Abstract:{{abstract}}
HeadlineImagePath:{{headlineimagepath}}
URL:{{url}}
Source:{{source}}
}, <------- This is the comma that I want to remove in the last repetition
{{/each}}
</pre>
</template>
如何在最后一次重复中声明以获取逗号? 我正在尝试类似的东西?:
{{#if newscount @index}} 但它不起作用。
【问题讨论】:
-
添加新助手。 islast:function(i){ return news.find().count() -1 === i;}
-
@alvespedro 这篇文章可能对stackoverflow.com/questions/21815713/… 有所帮助
标签: meteor meteor-blaze