My app consists of two pages, Homepage and Dashboard. On the Homepage, I want to show Login (top nav) and Register (main body). If the user is logged in then show the Dashboard. On the Dashboard I want to show Logout option. On logout show the Homepage.
Problem: When I try to update the Dashboard template, all of the content ends up going directly into the navbar. What is equally confusing is the body content from the Homepage page is still being rendered in the Dashboard page. I'm obviously overlooking something but I can't tell if it's an error in my code or in my understanding of templates and routes.
In use: Iron-Router, Accounts-UI and Accounts-password, Twbs:bootstrap.
Inserted below are the three main templates Master, Homepage and Dashboard.
Thanks in advance for any help you're able to provide!
Master template with if logged in logic
<template name="MasterLayout">
{{> yield}}
<nav class="navbar navbar-inverse navbar-fixed-top">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#">THE BRAND</a>
</div>
<div id="navbar" class="navbar-collapse collapse">
{{#if currentUser}}
{{> Dashboard}}
{{else}}
{{> Login}}
{{/if}}
</div><!--/.navbar-collapse -->
</div>
</nav>
</template>
Homepage holds the main content
<template name="Homepage">
<div class="jumbotron">
<div class="container">
<h1>Get it now..</h1>
<p>Donec id elit</p>
{{#if currentUser}}
hello
{{else}}
{{> Register}}
{{/if}}
</div>
</div>
</template>
Dashboard holds a placeholder text
<template name="Dashboard">
<ul class="nav navbar-nav">
<li class="navbar-text">Navigation Placeholder</li>
<li><a href="#" class="logout">Logout</a></li>
</ul>
</template>
I created the following controllers;
Homepage
HomepageController = RouteController.extend({
layoutTemplate: 'MasterLayout',
subscriptions: function() {
},
action: function() {
this.render('Homepage');
}
});
Dashboard
DashboardController = RouteController.extend({
layoutTemplate: 'Dashboard',
subscriptions: function () {
},
data: function () {
},
action: function () {
this.render('Dashboard', { /* data: {} */});
}
});