The core implementation of Twig now supports container parameters to enable debugging, auto-reloading templates, and caching compiled templates. The following container parameters are set in sites/example.com/services.yml
by default:
parameters:
twig.config:
debug: false
auto_reload: null
cache: true
Note that if twig_debug
is set to true
, then twig_auto_reload
also defaults to true
unless it is explicitly set otherwise.
With debugging enabled, Twig templates will be wrapped with HTML comments like so:
<!-- THEME DEBUG -->
<!-- CALL: theme('node') -->
<!-- FILE NAME SUGGESTIONS:
* node--article.html.twig
* node--2.html.twig
x node.html.twig
-->
<!-- BEGIN OUTPUT from 'core/modules/node/templates/node.html.twig' -->
<article id="node-1" class="node node-article promoted view-mode-full clearfix" role="article" about="/node/1" typeof="sioc:Item foaf:Document">
<p>(content)</p>
</article>
<!-- END OUTPUT from 'core/modules/node/templates/node.html.twig' -->
This output should help themers determine which template is being rendered, which theme suggestions are available and which theme and/or template suggestion has been selected for each piece of theme output.