Skip to content

Using key / context in helpers #1840

Open
@btalb

Description

@btalb

Consider the following two uses of a custom helper that needs to know information about the evaluation context in which it's been run:

{{#each robots}}
{{helperThatNeedsToKnowWhichRobot this}}
{{/each}}
{{#with robots.husky}}
{{helperThatNeedsToKnowWhichRobot this}}
{{/with}}

In the first case, my helper receives an options object with the following useful data fields:

    data: {                                                                                              
      root: [Object],                                                                                    
      _parent: [Object],                            
      key: 'husky',                                 
      index: 2,                                     
      first: false,                                 
      last: false                                   
    },  

But the second example gives me nothing to work with:

    data: { root: [Object] }

How can I implement the described helper which will also work in a with evaluation context?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions