wbond / pybars3

Handlebars.js template support for Python 3 and 2
GNU Lesser General Public License v3.0
179 stars 46 forks source link

../ does not work #5

Closed adambom closed 9 years ago

adambom commented 10 years ago

Putting ../ within any block helper does not give you a reference to the parent scope.

FYI: for anyone else having this problem, the workaround is to use a helper called include_parent:

def include_parent(this, options, *args, **kwargs):
    this.context['parent'] = this.parent
    return options['fn'](this)

Put it in your templates like so:

{{#each foo}}
    {{#include_parent}}
    {{parent.bar}}
{{/each}}
wbond commented 9 years ago

I believe this should be working. There are quite a number of tests that use the ../ syntax. As of the summer 2014, support for @_parent was also added.

wbond commented 9 years ago

Feel free to reopen or create a new issue if you can provide an example that fails.