I'm trying to work out how to do something really simple but it has me stumped.
I'm trying to simply display the user name and some of the profile parameters of the currently logged in user and I'm not getting far.
The searching I've done so far seems to indicate that I need to use a helper function to access things like
Meteor.user().profile.name
setting it to a variable that I can then use in handlebars. Is this correct?
Is it not possible to simply
{{Meteor.user().profile.name}}
in the template and have it display?
This certainly isn't working for me.
Edit to show code.... Sorry, should have put this in earlier.
The code I'm using is as follows. currentUser (as I'm now using thanks to answer below) is obviously defined as the loggedInPageLayout is displaying, but I can't get any information out of currentUser either on this page or on the loggedInPageLayout page.
template name="loginPage">
<div>
{{#if currentUser}}
<div>
You are logged in {{currentUser.username}}
{{> loggedInPageLayout}}
</div>
{{else}}
{{> loginPageLayout}}
{{/if}}
</div>
</template>
Peter.
You can use the currentUser helper, which returns Meteor.user()
:
{{currentUser.profile.name}}
Sorry, found my problem. I'm creating these test users in the startup code of my app. It seems the fields I thought I was populating I'm not.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With