Consider the following minimal example of handlebars Javascript.
{{#each arr as | topLevel topIndex |}}
{{topLevel.value}}
{{#each topLevel.children as | secondLevel secondIndex |}}
---- {{topLevel.value}}, {{secondLevel.value}}
{{#each secondLevel.children as | thirdLevel thirdIndex |}}
-------- {{topLevel.value}}, {{secondLevel.value}}, {{thirdLevel.value}}
{{/each}}
{{/each}}
{{/each}}
It works happily and renders the following:
ABC
---- ABC, DEF
-------- ABC, DEF, GHI
-------- ABC, DEF, JKL
---- ABC, MNO
-------- ABC, MNO, PQR
-------- ABC, MNO, STU
XYZ
---- XYZ, LMN
-------- XYZ, LMN, OPQ
-------- XYZ, LMN, RST
---- XYZ, UVW
-------- XYZ, UVW, XYZ
-------- XYZ, UVW, ABC
Notice how in each nested “each” block I can access variable names established within the | |
of prior each blocks. I do not need to include anything special such as ../
in order to access them.
My question is how can I achieve completely identical results in PHP’s Lightncandy library (the PHP implementation of handlebars) Currently with the following flags…
LightnCandy::FLAG_ERROR_LOG | LightnCandy::FLAG_STANDALONEPHP | LightnCandy::FLAG_HANDLEBARSJS | LightnCandy::FLAG_ADVARNAME | LightnCandy::FLAG_SPVARS | LightnCandy::FLAG_PARENT | LightnCandy::FLAG_JSTRUE | LightnCandy::FLAG_JSOBJECT,
… each nested else statement loses access to previous alias’s and index variables set in higher-level loops.
I really need this to work so I am hoping there is a flag or configuration that can make lightncandy behave like the JS implementation.