I have several codes that I want to run only when there is noUser and several when there is currentUser .
All this is inside the navigation template. So ...
{{#if currentUser}} <li class="nav"><a href="{{pathFor 'create'}}">Post</a> </li> <li class="nav"><a>Ola, {{thisUser}}!</a> </li> <li class="nav"><a href="#" id="logout">Log Out</a> </li> {{/if}} {{#if noUser}} <li class="nav"><a href="{{pathFor 'signup'}}">Sign Up</a> </li> <li class="nav"><a href="{{pathFor 'login'}}">Login</a> </li> {{/if}}
So, the problem is that when there is currentUser (i.e., Iām logged in), and I refresh the page, the code inside the {{#if noUser}} block is displayed first, and then the {{#if currentUser}} block, while the {{#if noUser}} block should only be displayed when there is no user.
Here is the helper code for the template.
Template.navigation.helpers({ thisUser: function () { return Meteor.user().username; }, noUser: function () { var user = Meteor.user(); if (!user) { return true; }; } });
Don't know what I'm doing wrong here. :(
Please, help.
metpb source share