The {{if ...}}
block adds another view, so means you need to add a .parent to step up through that view, as in: {{:#parent.parent.parent.data.myproperty}}
You can pass in variables as you said (~myproperty=...
) and they will be visible to any depth of nesting.
Your variable can be an object too such as the current data object: ~myObj=#data
:
{{sometag a=b ~myObj=#data}}
....
{{:~myObj.myproperty}}
...
{{/sometag}}
so you don't need a separate variable for each property.
You can also access the top-level data object and drill down from there:
{{:~root.foo...myproperty}}
.
And finally you can use #get("item")
to step up through any number of {{if}}
blocks and get the nearest "item" view (i.e. the item view for a repeating {{for ...}}
block).
So you would write:
{{:#get("item").data.myproperty}}