From 3f9453c8ea0ef4a39eac17525d73b1aae347be46 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Sun, 28 Nov 2010 16:55:40 +0100 Subject: [PATCH] added doc for the optimizer extension --- doc/03-Twig-for-Developers.markdown | 20 +++++++++++++++++++- 1 files changed, 19 insertions(+), 1 deletions(-) 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 ---------- -- 1.7.2.5