custom helpers inside each block
- by Unspecified
myArray = [{name: "name1", age: 20}, {name: "name2", age:22}];
{{#each person in myArray}}
{{#myHelper person}}
Do something
{{/myHelper}}
{{/each}}
Handlebars.registerHelper(function(context, options){
if(context.age > 18){
return options.fn(this);
}else{
return options.inverse(this);
}
})
In the above code when I tried to debug my custom helper it shows the context="person" while I want the context to be the person object, what's wrong with my code ?
I found a similar question here but did not get it either...