title: Accessing parent context in Meteor templates and template helpers
body: <p>I'm running into a template context situation that I'm having a hard time finding a way around.</p>
  
  <p><br />
  <strong>Here's the template in question:</strong></p>
  
  <pre><code>{{#each votes}}
      &lt;h3&gt;{{question}}&lt;/h3&gt;
  
      &lt;ul&gt;
          {{#each participants}}
              &lt;li&gt;
                  &lt;p&gt;{{email}}&lt;/p&gt;
                  &lt;select name="option-select"&gt;
                      {{#each ../options}}
                      &lt;option value="{{option}}" class="{{is_selected_option}}"&gt;{{option}}&lt;/option&gt;
                      {{/each}}
                  &lt;/select&gt;
              &lt;/li&gt;
          {{/each}}
      &lt;/ul&gt;
  &lt;/div&gt;
  {{/each}}
  </code></pre>
  
  <p><br />
  <strong>And here's an example of a vote document:</strong></p>
  
  <pre><code>{
      _id: '32093ufsdj90j234',
      question: 'What is the best food of all time?'
      options: [
          'Pizza',
          'Tacos',
          'Salad',
          'Thai'
      ],
      participants: [
          {
              id: '2f537a74-3ce0-47b3-80fc-97a4189b2c15'
              vote: 0
          },
          {
              id: '8bffafa7-8736-4c4b-968e-82900b82c266'
              vote: 1
          }
      ]
  }
  </code></pre>
  
  <p><br />
  <strong>And here's the issue...</strong></p>
  
  <p>When the template drops into the <code>#each</code> for participants, it no longer has access to the <code>vote</code> context, and therefore doesn't have access to the available options for each vote.</p>
  
  <p>I can <em>somewhat</em> get around this by using the <code>../options</code> handlebars path to jump back into the parent context, but this doesn't affect the context of the template helper, so <code>this</code> in <code>Template.vote.is_selected_option</code> refers to the current <code>participant</code>, not to the current <code>vote</code> or <code>option</code>, and has no way of knowing which <code>option</code> we are currently iterating through.</p>
  
  <p>Any suggestions on how to get around this, without resorting to DOM manipulation and jQuery shenanigans? </p>
  
  <p>This is a templating issue that has come up multiple times for me. We need a formal way of reaching up the template context hierarchy, in templates, template helpers, and template events.</p>