The Vardot Team: 10 Twig Tricks for Better Drupal Theming

Twig is the theming engine that Drupal uses, at least after Drupal 8. It's a templating engine that is developer-friendly and designer-friendly. Its syntax is intuitive, logical, and flexible. In this post, we will cover 10 Twig tricks that will enhance your Drupal theming process, and make theming fun and productive.   1. The Debugger Debugging is the gateway to understanding, so before any tips or tricks, the Twig debugger must be enabled. This will add HTML comments around template suggestions and show which template is being used. In services.yml, set  twig.config: debug: true auto_reload: true cache: false Using dump() for inspection {{ dump(content) }} // for cleaner outputs, install Devel and use kint() {{ kint(content) }}  
PubDate

Tags