Theming : enable Twig templates Debug | Drupal 8

Theming : enable Twig templates Debug

Submitted by editor on Wed, 04/27/2016 - 12:28
Question

How to enable Twig templates Debug ? Debugging Twig templates.

 

Enable debugging

You enable Twig Debugging in sites/default/services.yml.
(If services.yml does not yet exist; copy default.services.yml and rename it to services.yml.)

parameters:
 twig.config:
  debug: true

Printing variables

{{ dump() }}
{{ dump(var) }}

Or If you have Devel's kint:

{{ kint() }}

 

Via Drush (On drupal 7, Not for D8)

drush vset theme_debug 1

 

Configuration override For theming and Integration.

To optimize performence, drupal compress and aggregate CSS / JS files. But for front side development we need to disable this function. You can do that from /admin/config/development/performance , and also via setting.php.

Disable CSS / JS preprocess by settings.php

$config['system.performance']['css']['preprocess'] = 0;
$config['system.performance']['js']['preprocess'] = 0;

Add new comment