【发布时间】:2016-04-22 07:46:23
【问题描述】:
我的流星应用程序具有以下基本布局:
<template name="layout">
{{> header}}
{{> yield}}
{{> footer}}
</template>
我的header 模板包含全角标题:
<template name="header">
<div>
<!--implementation of full-width header-->
<h1>{{pageTitle}}</h1>
<!--insert custom html here, e.g. search input or options (see screenshot)-->
</div>
</template>
然后,我有多个yield 模板,这就是主要内容所在。
对于我的每个yield 模板,我希望能够将自定义内容“加载”到我的header 模板中:
- 设置
pageTitle属性,这样我在每个路由页面上都有一个自定义标题 - 插入一些 html 内容,例如做显示一些扩展选项(在这个例子中它是关于过滤查询结果,但基本上它是 html 内容)
最好的方法是什么?
编辑
我想出了以下内容。我在布局中添加了另一个基本模板,我们称之为headerYield:
<template name="layout">
{{> header}}
{{> headerYield}}
{{> yield}}
{{> footer}}
</template>
所有自定义标记都会放在那里,缺点是每个视图需要 2 个自定义模板。
【问题讨论】:
标签: meteor meteor-blaze spacebars