From c05b5bf52af1468ddd95356f5d3f42d9c2ee3302 Mon Sep 17 00:00:00 2001 From: catch <catch@35733.no-reply.drupal.org> Date: Wed, 6 Feb 2013 16:04:35 +0000 Subject: [PATCH] Issue #1843034 by Cottser, japerry, heyrocker, steveoliver, c4rl: Make Twig settings configurable. --- core/lib/Drupal/Core/CoreBundle.php | 8 +++---- sites/default/default.settings.php | 36 +++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+), 5 deletions(-) diff --git a/core/lib/Drupal/Core/CoreBundle.php b/core/lib/Drupal/Core/CoreBundle.php index a90415c66433..4ec42b9e2351 100644 --- a/core/lib/Drupal/Core/CoreBundle.php +++ b/core/lib/Drupal/Core/CoreBundle.php @@ -368,7 +368,7 @@ protected function registerTwig(ContainerBuilder $container) { // This is saved / loaded via drupal_php_storage(). // All files can be refreshed by clearing caches. // @todo ensure garbage collection of expired files. - 'cache' => TRUE, + 'cache' => settings()->get('twig_cache', TRUE), 'base_template_class' => 'Drupal\Core\Template\TwigTemplate', // @todo Remove in followup issue // @see http://drupal.org/node/1712444. @@ -376,10 +376,8 @@ protected function registerTwig(ContainerBuilder $container) { // @todo Remove in followup issue // @see http://drupal.org/node/1806538. 'strict_variables' => FALSE, - // @todo Maybe make debug mode dependent on "production mode" setting. - 'debug' => TRUE, - // @todo Make auto reload mode dependent on "production mode" setting. - 'auto_reload' => FALSE, + 'debug' => settings()->get('twig_debug', FALSE), + 'auto_reload' => settings()->get('twig_auto_reload', NULL), )) ->addMethodCall('addExtension', array(new Definition('Drupal\Core\Template\TwigExtension'))) // @todo Figure out what to do about debugging functions. diff --git a/sites/default/default.settings.php b/sites/default/default.settings.php index 8dbb5a71b190..4c1239ab2493 100644 --- a/sites/default/default.settings.php +++ b/sites/default/default.settings.php @@ -283,6 +283,42 @@ */ $settings['update_free_access'] = FALSE; +/** + * Twig debugging: + * + * When enabled, you can use the 'dump' function in Twig templates to output + * information about variables, and templates are automatically recompiled + * whenever the source code changes. + * + * @see http://drupal.org/node/1906392 + * + * Not recommended in production environments (Default: FALSE). + */ +# $settings['twig_debug'] = TRUE; + +/** + * Twig auto-reload: + * + * Automatically recompile Twig templates whenever the source code changes. If + * you don't provide a value for twig_auto_reload, it will be determined based + * on the value of twig_debug. + * + * Not recommended in production environments (Default: NULL). + */ +# $settings['twig_auto_reload'] = TRUE; + +/** + * Twig cache: + * + * By default, Twig templates will be compiled and stored in the filesystem to + * increase performance. Disabling the Twig cache will recompile the templates + * from source each time they are used. In most cases the twig_auto_reload + * setting above should be enabled rather than disabling the Twig cache. + * + * Not recommended in production environments (Default: TRUE). + */ +# $settings['twig_cache'] = FALSE; + /** * External access proxy settings: * -- GitLab