Fix twig end tags, fixes #617
Shorter code for twig tags generation
Merge branch 'fix_twig_end_tags'