[feature/twig] Fix begin loops & subloops

PHPBB3-11598