【发布时间】:2014-01-20 07:50:14
【问题描述】:
知道如何让我的 BioPic Handlebars 助手(我正在使用 Meteor)为参数“所有者”提供不同的上下文。我将 showBioPic 称为来自另一个模板的部分,即
<template name="myMain">
{{#each post}}
{{> showBioPic}}
{{/each}}
Do a bunch of other stuff here too.
</template>
我希望能够根据调用模板传递不同的“所有者”值,即 Meteor.userId、post.owner、anotherUsersId。即如果我使用 {{#each user}} 这没有所有者字段,它有一个 userId,所以 BioPic 助手将不起作用。
<template name="showBioPic">
{{#with BioPic owner}}
<img src="{{cfsFileUrl 'size48x48gm'}}" alt="Profile Picture: {{_id}}">
{{else}}
<img class="showShared" src="images/default-biopic-48x48.png" alt="Default Profile Picture">
{{/with}}
</template>
Template.showBioPic.BioPic = function (IN_ownerId)
return BioPicsFS.findOne( { owner: IN_ownerId });
};
【问题讨论】:
标签: javascript meteor handlebars.js