【发布时间】:2015-02-15 12:40:40
【问题描述】:
我正在尝试在 Iron: Router 中设置 layoutTemplate。我已经阅读了我在自己的项目中实现的文档(以减少重复代码)。不过有些不对劲。内部模板正在渲染,但不是布局。
位于'client/templates/defaultlayout.html'的布局文件
<template name="defaultlayout">
<head>
<title>Grocery Getter</title>
</head>
<div class="container">
<header>
{{> yield "headerButtons"}}
<h1>{{title}}</h1>
{{> loginButtons}}
{{> yield "headertextinput"}}
</header>
<body>
{{> yield}}
</body>
</div>
</template>
这是我要填充位于“client/templates/login.html”的“{{> yield}}”部分的模板:
<template name="login">
<h4>Please login or create an account.</h4>
</template>
这是我的 Iron:位于 'client/routes.js' 的路由器东西:
Router.configure({
layoutTemplate: 'defaultlayout'
});
Router.route('/',function()
{
if(!Meteor.user())
{
this.redirect('/login');
}
else
{
this.redirect('/householdsignup');
}
});
Router.route('/login',function()
{
if(!Meteor.user())
{
this.render('login', function(){
data: 'Grocery Getter'
});
}
else
{
this.redirect('/householdsignup');
}
});
我不确定我在这里做错了什么。
提前感谢您的帮助!!!
【问题讨论】:
标签: javascript meteor iron-router