War*_*arz 11 javascript meteor iron-router
我正在使用blaze-integrationIR 的新分支,并对现有应用程序进行了必要的更改.我在我的一个模板中有一个yield区域:
<div>
{{> yield region='signup-detail'}}
</div>
Run Code Online (Sandbox Code Playgroud)
我想在路由配置中使用设置此区域yieldTemplates.我的路线配置如下:
this.route('signUpInfo', {
path: '/sign-up',
template: 'signUp-form',
yieldTemplates: _.extend({}, mainYieldTemplates, {
'information': {to: 'signup-detail'}
})
});
mainYieldTemplates = {
'footer': { to: 'footer' },
'header': {to: 'header'}
};
Run Code Online (Sandbox Code Playgroud)
我的模板"信息"未呈现signup-detail.只有新的鲨鱼分支和IR火焰发生,使用Yield模板有什么变化?
页脚和标题模板设置正确.
编辑:模板布局
<template name="basicLayout">
{{> yield region='header'}}
<div class="container">
<div class="row">
<div class="col-md-12 col-centered padding-top-four-em">
{{> yield}}
</div>
</div>
<hr>
<footer>
{{> yield region='footer'}}
</footer>
</div>
</template>
Run Code Online (Sandbox Code Playgroud)
编辑2:SignUp表单模板
<template name="signUp-form">
<div class="col-md-12 signup-container">
{{>signUpSideBar}}
<div class="col-md-9 signup-content gray-border-box">
{{> yield region='signup-detail'}}
</div>
</div>
</template>
Run Code Online (Sandbox Code Playgroud)
注意:signUp-form模板有一个区域signup-detail.这是我的路线signUpInfo需要将information模板渲染到该区域的地方.这曾经在火焰整合之前在IR中工作.
我不知道它是一种完美的渲染方式.但它对我有用
Router.route('/', function () {
// use the template named ApplicationLayout for our layout
this.layout('ApplicationLayout');
// render the Post template into the "main" region
// {{> yield}}
this.render('Post');
// render the PostAside template into the yield region named "aside"
// {{> yield "aside"}}
this.render('PostAside', {to: 'aside'});
// render the PostFooter template into the yield region named "footer"
// {{> yield "footer"}}
this.render('PostFooter', {to: 'footer'});
});
Run Code Online (Sandbox Code Playgroud)
<template name="ApplicationLayout">
<header>
<h1>{{title}}</h1>
</header>
<aside>
{{> yield "aside"}}
</aside>
<article>
{{> yield}}
</article>
<footer>
{{> yield "footer"}}
</footer>
</template>
Run Code Online (Sandbox Code Playgroud)
<template name="Post">
<p>
{{post_content}}
</p>
</template>
<template name="PostFooter">
Some post specific footer content.
</template>
<template name="PostAside">
Some post specific aside content.
</template>
Run Code Online (Sandbox Code Playgroud)
看起来您的{{> yield region='signup-detail'}}产量模板不在您的产量模板中,因此路由器无法找到注册详细信息区域来插入您的“信息”模板。
{{> yield}}在你的yieldTemplate中正在呈现“signUp-form”(来自你template:的路线中的分配。
如果您的“signup-detail”模板是“signUp-form”内的模板,则只需使用{{> signup-detail}}.
如果您希望“signup-detail”作为layoutTemplate的一部分在多个模板中重复使用,请添加{{> yield region='signup-detail'}}到您的yieldTemplate中。