我有这个帮手
Template.clientesPromo.helpers({
'mostrarPromosCliente' : function(){
return Promociones.find({'metadata.modalCliente' : Session.get("val") });
}
})
并像这样使用
<template name="clientesPromo">
{{#each mostrarPromosCliente}}
<p style="color:#666; display: inline-block;">{{metadata.diaOferta}}</p>
{{/each}}
</template>
这是有效的回归例如星期一,星期二等,但我想做下一个
如果diaOferta等于星期一,星期二等(一周中的7天)帮助者返回“周的所有日子”而不是星期一,星期二等,
note mongo上的数据,其名称为metadata.diaOferta,其数组为天数
它有办法实现这个目标吗?
答案 0 :(得分:4)
<template name="clientesPromo">
{{#each mostrarPromosCliente}}
<p style="color:#666; display: inline-block;">{{getValue}}</p>
{{/each}}
</template>
创建另一个帮手
Template.clientesPromo.helpers({
'mostrarPromosCliente' : function(){
return Promociones.find({'metadata.modalCliente' : Session.get("val") });
},
'getValue':function(){
//here you can access metadata.modalCliente using **this.metadata.modalCliente**
var days=this.metadata.modalCliente;
//logic to checkj whether all days exists or not
if(allDays){
return "all days of the week"
}
else{
return this.metadata.modalCliente;
}
}
})