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.
{{#each person in persons}}
<span class="name">{{person.name}}</span>
{{/}}
Template.whatever.helpers({
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
}
};
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">
{{/with}}
{{/}}
from helper you can use for example something like this
Blaze.getData(Template.instance().$('.checker'))
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