Early Bird Registration for DrupalCon Portland 2024 is open! Register by 23:59 PST on 31 March 2024, to get $100 off your ticket.
Steps to reproduce:
Either:
- Prepare files for a clean install, copy default.services.yml to services.yml
- Edit services.yml so that twig.config.strict_variables = true
- Attempt install : works in Drush, not in the UI
Or:
- Prepare files for a clean install, copy default.services.yml to services.yml
- Install in Drush or the UI
- Edit services.yml so that twig.config.strict_variables = true
- Run
drush cr
- Browse to site: crash because classy uses {{ node_type }} which is undefined. Other undefined variable errors occur if that one is fixed
Enabling strict_variables
in Twig is an important element to ensure template quality, much like setting error_reporting
to the maximum. Drupal core should not rely on a relaxed setting like strict_variables = false
. This is Twig default to ease Twig adoption, but not a good practice when developing.
Comments
Comment #1
star-szrThanks for the report @fgm, please direct your attention to #2445705: Core themes should not throw exceptions when strict_variables is TRUE and join the discussion there, or reopen if you disagree that it's a duplicate.
Comment #2
fgm@Cottser. It's definitely a duplicate : I wonder why it did not appear when I search the issue queue for strict_variables, though ; but I see it appears now so let keep this one closed and continue on the other one.