#TwigEverywhere

Twig All The Things meme (#TwigEverywhere)

Twig is an incredibly powerful templating system that is still underused in Drupal.

It has the potential to make MANY things possible to sitebuilders that were previously only available through custom code, views hooks and other bits of behind-the-scenes tricker that can make it confusing to figure out what a site is doing.  

For this reason, we are promoting our #TwigEverywhere campaign to tag issues that will add Twig support in more and more of Drupal.

Twig is currently available in the following locations:

  • Template files (duh)
  • Views field rewrites

I would like to see Twig added in the following places:

  • Core
    • Views
      • Filter values
        • Would allow things like "where Changed >= {{ user.last_login }}" which can't currently be done in the UI
      • Header / Footer / No Results
        • Header/Footer can use Twig in the Unformatted Text field, but only if the Format is Fields.  It won't work with rendered entity Content displays.
  • Contrib

This article will be updated as new Twig support is added and new places it should be supported are identified.

Twig Security Note:  DO NOT allow any untrusted user to be able to put in Twig code.  It has critical security implications (similar to PHP Filter's risks) and should only be editable by admins and trusted moderators.