From: Fabien Potencier Date: Thu, 2 Dec 2010 09:26:45 +0000 (+0100) Subject: made the Escaper and Optimizer extensions enabled by default X-Git-Url: http://git.silmor.de/gitweb/?a=commitdiff_plain;h=2fe655fa2abb39f4b65b203857509a9878878b0a;p=web%2Fkonrad%2Ftwig.git made the Escaper and Optimizer extensions enabled by default --- diff --git a/CHANGELOG b/CHANGELOG index d6d0c1a..f493b4b 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,5 +1,6 @@ * 0.9.10 + * made the Escaper and Optimizer extensions enabled by default * fixed sandbox extension when used with auto output escaping * fixed escaper when wrapping a Twig_Node_Print (the original class must be preserved) * added an Optimizer extension diff --git a/doc/02-Twig-for-Template-Designers.markdown b/doc/02-Twig-for-Template-Designers.markdown index 1435422..ae222f6 100644 --- a/doc/02-Twig-for-Template-Designers.markdown +++ b/doc/02-Twig-for-Template-Designers.markdown @@ -416,7 +416,8 @@ The default configuration is no automatic escaping for various reasons: escaped HTML. >**NOTE** ->Escaping is only supported if the *escaper* extension has been enabled. +>Escaping is only supported if the *escaper* extension has been enabled (which +>is the default). ### Working with Manual Escaping @@ -428,8 +429,6 @@ the variable through the `|e` filter: `{{ user.username|e }}`. ### Working with Automatic Escaping -Automatic escaping is enabled when the `escaper` extension has been enabled. - Whether automatic escaping is enabled or not, you can mark a section of a template to be escaped or not by using the `autoescape` tag: diff --git a/doc/03-Twig-for-Developers.markdown b/doc/03-Twig-for-Developers.markdown index 55d152a..b0f3e34 100644 --- a/doc/03-Twig-for-Developers.markdown +++ b/doc/03-Twig-for-Developers.markdown @@ -241,6 +241,13 @@ Twig comes bundled with the following extensions: * *Twig_Extension_Optimizer*: Optimizers the node tree before compilation (as of Twig 0.9.10). +The core, escaper, and optimizer extensions do not need to be added to the +Twig environment, as they are registered by default. You can disable an +already registered extension: + + [php] + $twig->removeExtension('escaper'); + Built-in Extensions ------------------- @@ -293,9 +300,6 @@ The `core` extension defines all the core features of Twig: * `escape` * `e` -The core extension does not need to be added to the Twig environment, as it is -registered by default. - ### Escaper Extension The `escaper` extension adds automatic output escaping to Twig. It defines a diff --git a/lib/Twig/Environment.php b/lib/Twig/Environment.php index 95cf91c..b8117bb 100644 --- a/lib/Twig/Environment.php +++ b/lib/Twig/Environment.php @@ -77,7 +77,11 @@ class Twig_Environment $this->charset = isset($options['charset']) ? $options['charset'] : 'UTF-8'; $this->baseTemplateClass = isset($options['base_template_class']) ? $options['base_template_class'] : 'Twig_Template'; $this->autoReload = isset($options['auto_reload']) ? (bool) $options['auto_reload'] : $this->debug; - $this->extensions = array('core' => new Twig_Extension_Core()); + $this->extensions = array( + 'core' => new Twig_Extension_Core(), + 'escaper' => new Twig_Extension_Escaper(), + 'optimizer' => new Twig_Extension_Optimizer(), + ); $this->strictVariables = isset($options['strict_variables']) ? (bool) $options['strict_variables'] : false; $this->runtimeInitialized = false; if (isset($options['cache']) && $options['cache']) {