added an optimizations options to Twig_Environment

This commit is contained in:
Fabien Potencier
2010-12-14 17:30:45 +01:00
parent 9e5b2becf4
commit f3f72bc455
2 changed files with 11 additions and 2 deletions
+4
View File
@@ -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
+7 -2
View File
@@ -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;