在流星模板中显示用户参数

Pet*_*Unn 8 handlebars.js meteor

我正在努力弄清楚如何做一些非常简单的事情,但这让我很难过.

我正在尝试简单地显示当前登录用户的用户名和一些配置文件参数,但我并没有走得太远.

到目前为止我所做的搜索似乎表明我需要使用辅助函数来访问类似的东西

Meteor.user().profile.name
Run Code Online (Sandbox Code Playgroud)

将它设置为我可以在把手中使用的变量.它是否正确?

难道不可能简单

{{Meteor.user().profile.name}} 在模板中,让它显示?

这当然不适合我.

编辑显示代码....对不起,应该早点把它.

我正在使用的代码如下.currentUser(因为我现在用下面的感谢回答)显然是定义为loggedInPageLayout被显示,但我不能得到任何信息从currentUser的用户可以在本页面或loggedInPageLayout页面上.

template name="loginPage">
<div>
  {{#if currentUser}}
    <div>
      You are logged in {{currentUser.username}}
      {{> loggedInPageLayout}}
    </div>
  {{else}}
    {{> loginPageLayout}}
  {{/if}}
</div>
</template>
Run Code Online (Sandbox Code Playgroud)

彼得.

Pep*_*L-G 17

您可以使用currentUser helper,它返回Meteor.user():

{{currentUser.profile.name}}