From f3f72bc455511c7e55ad7a93cfe3358ff8a12453 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Tue, 14 Dec 2010 17:30:45 +0100 Subject: [PATCH] added an optimizations options to Twig_Environment --- doc/03-Twig-for-Developers.markdown | 4 ++++ lib/Twig/Environment.php | 9 +++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/doc/03-Twig-for-Developers.markdown b/doc/03-Twig-for-Developers.markdown index 3bc9f4b..c2bd26e 100644 --- a/doc/03-Twig-for-Developers.markdown +++ b/doc/03-Twig-for-Developers.markdown @@ -98,6 +98,10 @@ The following options are available: * `autoescape` (new in Twig 0.9.10): If set to `true`, auto-escaping will be enabled by default for all templates (default to `true`). + * `optimizations` (new in Twig 0.9.10): A flag that indicates which + optimizations to apply (default to `-1` -- all optimizations are enabled; + set it to `0` to disable). + >**CAUTION** >Before Twig 0.9.3, the `cache` and `auto_reload` options did not exist. They >were passed as a second and third arguments of the filesystem loader diff --git a/lib/Twig/Environment.php b/lib/Twig/Environment.php index d7afc2c..136f148 100644 --- a/lib/Twig/Environment.php +++ b/lib/Twig/Environment.php @@ -58,7 +58,11 @@ class Twig_Environment * * strict_variables: Whether to ignore invalid variables in templates * (default to false). * - * * autoescape: Whether to enable auto-escaping (default to true). + * * autoescape: Whether to enable auto-escaping (default to true); + * + * * optimizations: A flag that indicates which optimizations to apply + * (default to -1 which means that all optimizations are enabled; + * set it to 0 to disable) * * @param Twig_LoaderInterface $loader A Twig_LoaderInterface instance * @param array $options An array of options @@ -92,6 +96,7 @@ class Twig_Environment 'autoescape' => true, 'cache' => false, 'auto_reload' => null, + 'optimizations' => -1, ), $options); $this->debug = (bool) $options['debug']; @@ -101,7 +106,7 @@ class Twig_Environment $this->extensions = array( 'core' => new Twig_Extension_Core(), 'escaper' => new Twig_Extension_Escaper((bool) $options['autoescape']), - 'optimizer' => new Twig_Extension_Optimizer(), + 'optimizer' => new Twig_Extension_Optimizer($options['optimizations']), ); $this->strictVariables = (bool) $options['strict_variables']; $this->runtimeInitialized = false; -- 1.7.2.5