I've got a hbs template where I've got an array of objects and a boolean toggle variable (toggles the template behavior), let's say:
{
objs: list,
mode: true
}
I'm not able to access the mode
variable when inside the loop over objs
(the context is changed). What I want is to make an if-statement using the upper variable. I found that I can write a custom helper. But is there no other way to access the variable? I also found out, that inside the loop the variable is accessible via {{../mode}}
- but still, don't know how to access that.
I've got a hbs template where I've got an array of objects and a boolean toggle variable (toggles the template behavior), let's say:
{
objs: list,
mode: true
}
I'm not able to access the mode
variable when inside the loop over objs
(the context is changed). What I want is to make an if-statement using the upper variable. I found that I can write a custom helper. But is there no other way to access the variable? I also found out, that inside the loop the variable is accessible via {{../mode}}
- but still, don't know how to access that.
- maybe its worth mentioning, I was looking for reference to global variable inside an each loop. this was actually what i was looking for thanks! – elad silver Commented Apr 7, 2015 at 12:48
1 Answer
Reset to default 17Finally, I've found a solution:
{{#if ../mode}}xyz{{/if}}