流星嵌套的视图和产量 [英] Meteor nested views and yields

查看:48
本文介绍了流星嵌套的视图和产量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Iam建立了我未来的流星应用程序的基本结构,Iam使用了流星和角度.想要将铁路由器与ui路由器结合使用,但是效果很差.因此,现在Iam回到了普通流星上来解决路由问题,任务是拥有标准的多页站点,但是其中一个页面是一个具有自己子页面的复杂面板.

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.

所以我有一个带有> yield的全局布局,并且所有内容都在其中呈现,现在此dasboard页面也已呈现为该yield,但是它必须具有自己的yield.如何设置路由器使其正常工作?如何准备模板?

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?

推荐答案

将首选路由器用于顶层路由,然后对于要插入到仪表板中的模板,请使用

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]}}

  • 选择要按名称动态包含的模板.

参数

  • 模板字符串 要包含的模板的名称.

  • template String The name of the template to include.

数据对象 选修的.要在其中包含模板的数据上下文.

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

Template.dynamic允许您按名称包含模板,该名称可以由助手计算出并且可以进行相应的更改. data参数是可选的,如果省略,则使用当前数据上下文.

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.

例如,如果有一个名为"foo"的模板,{{> Template.dynamic template ="foo"}}等效于{{> foo}}.

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

这是一个教程.

这篇关于流星嵌套的视图和产量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆