使用流星的 currentUser 助手链接条件
Chaining conditions using meteors' currentUser helper
我在 m 模板文件中使用 currentUser 助手,我想知道我是否可以实现这一点。
<h5 class="panel-title"> {{#if currentUser.profile.userrole = 'schooladmin' or 'teacher' or 'student' or 'parent' or 'superadmin'}} Academic Years {{/if}}</h5>
我想使用 if or 语句进行链接。
上述链接导致此错误
Can't have a non-keyword argument
after a keyword argument
我该如何纠正这个问题?
无需在 Blaze 中执行所有这些操作,只需创建一个助手并在您的视图中调用它即可。
Template.xxx.helpers({
customLogic: function() {
return (Meteor.user().profile.userrole === 'schooladmin' || other logics);
}
});
{{#if customLogic}}
Academic Years
{{/if}}
我吃过全球帮手
Template.registerHelper("custom", function() {
return (Meteor.user().profile.userrole === 'schooladmin' || 'teacher' || 'student' || 'parent' || 'superadmin');
});
并像这样使用它
<h5 class="panel-title"> {{#if custom}} Academic Years{{/if}}</h5>
我在 m 模板文件中使用 currentUser 助手,我想知道我是否可以实现这一点。
<h5 class="panel-title"> {{#if currentUser.profile.userrole = 'schooladmin' or 'teacher' or 'student' or 'parent' or 'superadmin'}} Academic Years {{/if}}</h5>
我想使用 if or 语句进行链接。
上述链接导致此错误
Can't have a non-keyword argument
after a keyword argument
我该如何纠正这个问题?
无需在 Blaze 中执行所有这些操作,只需创建一个助手并在您的视图中调用它即可。
Template.xxx.helpers({
customLogic: function() {
return (Meteor.user().profile.userrole === 'schooladmin' || other logics);
}
});
{{#if customLogic}}
Academic Years
{{/if}}
我吃过全球帮手
Template.registerHelper("custom", function() {
return (Meteor.user().profile.userrole === 'schooladmin' || 'teacher' || 'student' || 'parent' || 'superadmin');
});
并像这样使用它
<h5 class="panel-title"> {{#if custom}} Academic Years{{/if}}</h5>