Handlebars array access with dynamic index
handlebars.js
Solution
Related to my answer on another question
You can use the built-in `lookup` helper:
The `lookup` helper allows for dynamic parameter resolution using Handlebars variables. This is useful for resolving values for array indexes.
Using `lookup`, your example could be written as
{{#each condition in conditions}}
{{#with (lookup ../App.ops condition.op)}}
{{name}}
{{/with}}
{{/each}}
(Note that without knowledge of the structure of your data, I'm making an assumption about the location of `App.ops`.)
Problem
How can I access to an array element inside handlebars template using a variable instead of an hardcoded value? I need to do something like: ``` {{#each condition in conditions}} {{App.ops.[condition.op].name}} {{/each}} ``` at the moment doesn't give me a parse error but on runtime doesn't return me nothing. If i do something like this: ``` {{App.ops.[1].name}} ``` it works but it's not what i'm looking for