I ran into a snag trying to share some templates between handlebars.js and handlebars java.handlebars.js requires a relative traversal up to the parent object when accessing an object property from within a block helper.
Handlebars java apparently will recursively look up the parent context for a property if it is not found in the current context, which is great, however since I am sharing templates I need to have consistent syntax.
So i tried using ../ to access parent properties within a block in handlebars.java, and it worked. However when i needed to go two parents up using ../../ it did not work at all.
Example:{{#each foo.bars}}
{{../foo.prop}} // works in both handlebars.js and handlbars java
{{if ../foo.cond}}
{{../../foo.prop}} // does not work in handlebars java, only works in handlebars.js
{{/if}}
{{/each}}
Any recommendations on how to solve this? It seems like the ../../ should still work in handlebars java. Is this a bug?
{ "prop":"foo", "objects":{ "prop":"foo", "prop2":"bar" }}{{#each hbstest.objects}} {{#each ../hbstest.objects}} {{../../hbstest.prop}} {{!--works in hbs java and handlebars.js--}} {{/each}}{{/each}}{{#each hbstest.objects}} {{../hbstest.prop}} {{!--works in hbs java and handlebars.js--}} {{#if ../hbstest.objects}} {{!-- conditional fires in both hbs java and handlebars.js--}} {{../../hbstest.prop}} {{!--only resolves in handlebars.js--}} {{/if}}{{/each}}