Jul 8th, 2016
Here's a couple of scripts to turn Twig debug mode on and off in Drupal 8. In these scripts, I source my .bash_profile which has an alias called "exampledrush" which switches to a project folder and uses the correct version of drush.
Here's a script to turn it on:
#!/bin/sh source ~/.bash_profile exampledrush D8SERVICESFILE="/Applications/MAMP/htdocs/example/docroot/sites/default/services.yml" if grep -q "debug: false" "$D8SERVICESFILE"; then perl -pi -e 's/debug: false/debug: true/g' "$D8SERVICESFILE" echo "Twig debug mode has been turned on" echo "Clearing Drupal caches" drush cr else echo "Twig debug mode is already on" fi
Here's a script to turn it off:
#!/bin/sh source ~/.bash_profile exampledrush D8SERVICESFILE="/Applications/MAMP/htdocs/example/docroot/sites/default/services.yml" if grep -q "debug: true" "$D8SERVICESFILE"; then perl -pi -e 's/debug: true/debug: false/g' "$D8SERVICESFILE" echo "Twig debug mode has been turned off" echo "Clearing Drupal caches" drush cr else echo "Twig debug mode is already off" fi