更新时间:2022-06-25 05:04:26
由于'viewpost'模板和'postlist'模板之间似乎没有太多内容重叠,因此我认为它实际上会更干净只需使用{{> viewpost currentPost}}
代替yield,并以编程方式设置currentPost.例如,在帖子列表模板中,您可以具有currentPost变量,该变量返回当前帖子的数据,如下所示:
Since there doesn't seem to be much of a content overlap between the 'viewpost' template and the 'postlist' template, I think it will actually be cleaner to just use {{> viewpost currentPost}}
in place of the yield, and set the currentPost programmatically. For example, in the postlist template, you can have a currentPost variable that returns the data for the current post, like so:
Template.postlist.helpers({
currentPost: function () {
return Posts.findOne(Session.get('currentPost'));
}
});
,只需单击发布列表模板中的链接即可设置会话.
and just set the Session when you click on the link in the postlist template.