twig.js: Some context is lost with a combination of extends, embed, include

I am losing some data variables in a certain situation on my site.

I gradually boiled the case down and have posted it in a gist: https://gist.github.com/tremby/62df667cf9fb9dc7a303

Pasting the output of the test2page.twig template here:

test2layout.twig 1      [foo]   [bar]
test2page.twig 1        [foo]   []
test2.twig 1            [foo]   []      [baz]
test2template.twig 1    []      []      [baz]
test2.twig 2            []      []      [baz]
test2template.twig 2    []      []      [baz]
test2.twig 3            [foo]   []      [baz]
test2page.twig 2        [foo]   []
test2layout.twig 2      [foo]   [bar]

The variable foo is set to ‘foo’ as part of the render function and the way I understand it, it should be available everywhere (I’m not doing include with “only” at any point). But it’s not available in the block test2.twig embeds within test2template.twig, or in the non-block parts of test2template.twig embedded in test2.twig. (This is the main problem.)

bar is set to ‘bar’ in the layout which test2page.twig extends, and I’m not sure whether that should then be available in test2page.twig and the file that this one includes. I would have thought it should, but it is not.

baz is set to baz in test2.twig, which is included by test2page.twig. It’s then available everywhere I’d expect.

Is this indeed a bug, or am I misunderstanding how things are supposed to work?

About this issue

  • Original URL
  • State: closed
  • Created 9 years ago
  • Comments: 27 (14 by maintainers)

Most upvoted comments

Hello, I just want to confirm that the problem is also solved for me when using v1.12.0. Thanks !

Thanks for doing that, I’ll include this when I’m testing.

Ok merged a few PRs.