I have a collection Postswhere everyone Postin the collection has a property userId. On my detailed message page, I want to associate a username with a link to their profile using an assistant pathFor. If I just paste {{pathFor 'userProfile'}}, it establishes a connection with Post _id, as expected, but I obviously need the userId in the link.
I tried to create a second data context in the template helper, but that didn't work either.
Script:
Template.postPage.helpers({
user: function () {
return {_id: this.userId};
}
});
Template:
<template name="postPage">
{{#with user}}<a href="{{pathFor 'userProfile'}}">{{/with}}{{author}}</a>
</template>
How can I use pathForwith a field userIdfrom my Postdoc instead of a field _idfrom my Postdoc?
I use an iron router if that matters.