【发布时间】:2015-04-29 05:21:55
【问题描述】:
我正在使用 Meteor.js 开展一个项目,但在使用 Handlebar 时遇到了一些问题:我想检索集合的最后一项,并显示字段:其中包含 html 的文本:
这是我的 javascript 代码:
Template.postVerif.helpers({
'lastPost' :function(){
lastPost = Posts.find({}, {sort:{timestamp:-1}, limit :1}).fetch();
return lastPost
}
})
在 html 中,车把 {{#each}} 正在工作,但 {{#with}} 没有 看到只有一件物品被退回,这有点奇怪。
{{#each lastPost}}
{{{text}}}
{{/each}}
{{#with lastPost}}
{{{text}}}
{{/with}}
你知道为什么会这样吗?
【问题讨论】:
标签: javascript meteor spacebars