custom helpers inside each block

Posted by Unspecified on Stack Overflow See other posts from Stack Overflow or by Unspecified
Published on 2012-11-19T10:55:17Z Indexed on 2012/11/19 11:01 UTC
Read the original article Hit count: 203

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...

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about ember.js