[PHPBB3-13132] Twig: move the loops content from loops. to the root context Created: 05/Oct/14  Updated: 06/Mar/15  Resolved: 06/Mar/15

Status: Unverified Fix
Project: phpBB3
Component/s: Template Engine
Affects Version/s: 3.1.0-RC4
Fix Version/s: 3.2.0-a1

Type: Improvement Priority: Blocker
Reporter: nicofuma Assignee: nicofuma
Resolution: Fixed Votes: 0
Labels: None

GitHub Pull Request URL: https://github.com/phpbb/phpbb/pull/3471


Currently the content of the BEGIN blocks are stored under a loops. sub context. So if we want to use a twig for in a template we need to either not call assign_block_vars at all or iterate over loops.var_name.

Instead we should move the content to the root context (like all the other variables) and then rename the inner variable:

{% for __inner.my_loop in my_loop%}{endfor} or 
{% for my_loop.__inner in my_loop%}{endfor}

instead of 
{% for my_loop in loops.my_loop%}{endfor}

Comment by nicofuma [ 05/Oct/14 ]

Actually we can't rename the inner variable due to the includes. So I see only 2 solutions:

  • 1 won't fix
  • 2 duplicate the content in the context
Generated at Sat Feb 16 08:28:10 UTC 2019 using Jira 7.12.3#712004-sha1:5ef91d760d7124da5ebec5c16a948a4a807698df.