made the Escaper and Optimizer extensions enabled by default
authorFabien Potencier <fabien.potencier@gmail.com>
Thu, 2 Dec 2010 09:26:45 +0000 (10:26 +0100)
committerFabien Potencier <fabien.potencier@gmail.com>
Thu, 2 Dec 2010 09:26:45 +0000 (10:26 +0100)
CHANGELOG
doc/02-Twig-for-Template-Designers.markdown
doc/03-Twig-for-Developers.markdown
lib/Twig/Environment.php

index d6d0c1a..f493b4b 100644 (file)
--- 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
index 1435422..ae222f6 100644 (file)
@@ -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:
 
index 55d152a..b0f3e34 100644 (file)
@@ -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
index 95cf91c..b8117bb 100644 (file)
@@ -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']) {