Meteor nested views and yields

牧云@^-^@ 提交于 2019-12-24 14:28:32

问题


Iam setting up a basic structure of my future meteor app, Iam using meteor and angular. Wanted to combine iron router with ui router but it got pretty bad. So now Iam back on vanilla meteor for routing issue and the task is have standard multipage site but one of the pages is a complex panel with its own subpages.

So I have a global layout with >yield and all content is being rendered there, now this dasboard page is also rendered into this yield, but it has to have yield of its own. How to set up router to make it work? How to prepare template?


回答1:


Use your preferred router for the top level routing, then for the templates you want to insert into the dashboard use Template.dynamic

{{> Template.dynamic template=template [data=data] }}

  • Choose a template to include dynamically, by name.

Arguments

  • template String The name of the template to include.

  • data Object Optional. The data context in which to include the template.

Template.dynamic allows you to include a template by name, where the name may be calculated by a helper and may change reactively. The data argument is optional, and if it is omitted, the current data context is used.

For example, if there is a template named "foo", {{> Template.dynamic template="foo"}} is equivalent to {{> foo}}.

Here is a tutorial.



来源:https://stackoverflow.com/questions/32980608/meteor-nested-views-and-yields

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!