I\'m running into a template context situation that I\'m having a hard time finding a way around.
Here\'s the template in question:
It's not particularly pretty, but I've done something like this:
{{#each augmentedParticipants}}
{{> participant }}
{{/each}}
...
Question: {{this.parent.question}}
...
// and in the js:
Template.forLoop.helpers({
augmentedParticipants: function() {
var self = this;
return _.map(self.participants,function(p) {
p.parent = self;
return p;
});
}
});
It's similar to the approach that AVGP suggested, but augments the data at the helper level instead of the db level, which I think is a little lighter-weight.
If you get fancy, you could try to write a Handlebars block helper eachWithParent that would abstract this functionality. Meteor's extensions to handlebars are documented here: https://github.com/meteor/meteor/wiki/Handlebars