Proposed a modernization of the Twig code

These are the main changes:

  * Use the `default` filter instead of the `if XXX is defined`
  * Use the `include()` function instead of the deprecated `{% include %}` tag
  * Use `for ... else ... endfor` instead of `if ... for ... endfor ... else ... endif`