简体   繁体   English

在模板之间传递数据的模式和实践

[英]Patterns and practices for passing data between templates

As of Meteor 1.1*, what are the best patterns and practices for passing data between templates using raw Meteor? 从Meteor 1.1 *开始,使用原始 Meteor在模板之间传递数据最佳模式做法是什么?

A link to the Meteor forum asking the same question. 询问相同问题的流星论坛链接

Some different possibilities: 一些不同的可能性:

With block: 带块:

{{#with post}}
    {{> postTemplate}}
{{/with}}

Passing arguments: 传递参数:

{{> postTemplate post=post anotherArg=5 moreData="xyz"}}

If you also want to use iron-router (and basically all projects should), you can use "data" to return the data context for the page you're loading. 如果您还想使用Iron-Router(基本上所有项目都应如此),则可以使用“数据”来返回要加载页面的数据上下文。

Also, note that child templates inherent parent data contexts. 另外,请注意,子模板是固有的父数据上下文。 (They don't inherent helpers though). (尽管他们不是天生的帮手)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM