From: Fabien Potencier Date: Sun, 28 Nov 2010 15:55:40 +0000 (+0100) Subject: added doc for the optimizer extension X-Git-Url: http://git.silmor.de/gitweb/?a=commitdiff_plain;h=3f9453c8ea0ef4a39eac17525d73b1aae347be46;p=web%2Fkonrad%2Ftwig.git added doc for the optimizer extension --- diff --git a/doc/03-Twig-for-Developers.markdown b/doc/03-Twig-for-Developers.markdown index 6cca0dc..55d152a 100644 --- a/doc/03-Twig-for-Developers.markdown +++ b/doc/03-Twig-for-Developers.markdown @@ -225,7 +225,7 @@ extension is as simple as using the `addExtension()` method: [php] $twig->addExtension(new Twig_Extension_Escaper()); -Twig comes bundled with four extensions: +Twig comes bundled with the following extensions: * *Twig_Extension_Core*: Defines all the core features of Twig and is automatically registered when you create a new environment. @@ -238,6 +238,9 @@ Twig comes bundled with four extensions: * *Twig_Extension_I18n*: Adds internationalization support via the gettext library. + * *Twig_Extension_Optimizer*: Optimizers the node tree before compilation (as + of Twig 0.9.10). + Built-in Extensions ------------------- @@ -450,6 +453,21 @@ PHP [documentation](http://fr.php.net/manual/en/function.gettext.php): >The chapter "Twig for Web Designers" contains more information about how to >use the `trans` block in your templates. +### Optimizer Extension (as of Twig 0.9.10) + +The `optimizer` extension optimizes the node tree before compilation: + + [php] + $twig->addExtension(new Twig_Extension_Optimizer()); + +By default, all optimizations are turned on. You can select the ones you want +to enable by passing them to the constructor: + + [php] + $optimizer = new Twig_Extension_Optimizer(Twig_NodeVisitor_Optimizer::OPTIMIZE_FOR); + + $twig->addExtension($optimizer); + Exceptions ----------