How to pass data from outer template to inner template?


#1

Suppose I have an outer template that contains an each block. This each block creates instances of an inner template. I want to pass data from the outer template to the innner template inside the each block. How do I pass data from the outer template to the inner template?

For example :

<template name='outer'>
    <!-- Works fine -->
    {{ >inner item=this.getSpecificItem list=getList }}
    
    <!-- Context is changed inside each block, can not access parent data -->
    {{ #each getItems }}
        {{ >inner item=this list=getList }}
    {{ /each }}
</template>

Template.outer.helpers({
  getSpecificItem: function () {
    return Items.findOne(this.itemId);
  }

  getList: function () {
    return Lists.findOne(this.listId);
  },
  
  getItems: function () {
    return Items.find({listId: this.listId});
  },
});

#2

there is a way to pass content
but there is also {{ .. }} which refers to parent template, so you can address {{ ../getList }} if I am using it right way