i want something like this
{{# if role.admin}}
<a href="/secret">only for all admin users</a>
{{/if}}
in my _header.html template, i use iron-roter, roles, and meteor-useraccount
maybe like (in _header.js)
Template._header.helpers({
currentRole: function(){
return Meteor.call('meteor_get_me_my_current_role')
}
})
Any idea? Thanks
Meteor.call on the client is asynchronous, so you need to provide a callback function for the method results. Secondly you need to take care of reactivity or your _header
template might not get the update. One way could be like this (assuming meteor_get_me_my_current_role returns a role object)
Template._header.onCreated(function(){
this.initialized = new ReactiveVar(false);
this.role = new ReactiveVar({admin: false});
});
Template._header.helpers({
currentRole: function() {
var template = Template.instance();
if(!template.initialized.get())
{
Meteor.call('meteor_get_me_my_current_role', function(err,res) {
if(!err) {
template.role.set(res);
template.initialized.set(true);
}
});
}
return template.role.get();
}
});