[ticket/11833] Fix bad template loop

PHPBB3-11833
[ticket/11833] Prevent Twig errors from invalid template loops using BEGINELSE

PHPBB3-11833
Merge pull request #1705 from EXreaction/ticket/11833

Fix invalid template loop & prevent Twig from throwing errors in invalid uses of BEGINELSE