Search code examples
javascriptmeteoriron-router

Meteor nested views and yields


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?


Solution

  • 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.