Let and each programmatically access to the new data


Hello Everybody

I have a question. How are we supossed to access a {{#let newVar=‘hello’}} or a {{#each obj in list}} programatically.
I mean, inside a helper or an event, you can access to the data context, but this variables are not there.

Thanks for your help!


I think they should. Can you please show us a small version of your code?

{{#each person in persons}}
     <span class="name">{{person.name}}</span>
    aHelper: function() {
        //I want to acces to person
        this.person //Doesn't work
        //IT seems like the new variable is not injected in the data context
        var data = Template.currentData();  //Didn't work


But where do you call the helper?


I dont think there is direct way how to access them.
But as usual there is ugly way, for example

{{#each person in persons}}
     <span class="name">{{person.name}}</span>
    {{#with person}}
        <div class="checker">

from helper you can use for example something like this


And from event handler also, pick it with another DOM query based on template parameter, or use directly event.currentTarget
I did not tested this code exactly, but you know what way I mean