流星交叉模板用户对象

时间:2013-01-26 11:54:18

标签: templates meteor

我想知道user()是一个可以在全部使用的对象

什么是最好和最安全的方式让它在所有tempaltes中可用?

{{app.user}}似乎不起作用

还是应该加入Session? 谢谢

1 个答案:

答案 0 :(得分:0)

您可以在客户端javascript中制作通用车把助手,例如:

Handlebars.registerHelper('user',function(){
   return Meteor.user();
});

例如,只要用户登录,模板中的任何位置都会使用它(如果您设置了配置文件名称):

{{user.profile.name}}