From aac6cb613cf27a05d79536507f3ec3880d75b60f Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Thu, 31 Jan 2013 09:30:58 +0100 Subject: [PATCH] Fixes and minor additions to the docs. --- doc/api.rst | 19 +++++++++++++++++-- doc/intro.rst | 2 +- doc/recipes.rst | 7 ++++--- 3 files changed, 22 insertions(+), 6 deletions(-) diff --git a/doc/api.rst b/doc/api.rst index 9160c3f..81856fd 100644 --- a/doc/api.rst +++ b/doc/api.rst @@ -312,9 +312,9 @@ Twig comes bundled with the following extensions: to escape/unescape blocks of code. * *Twig_Extension_Sandbox*: Adds a sandbox mode to the default Twig - environment, making it safe to evaluated untrusted code. + environment, making it safe to evaluate untrusted code. -* *Twig_Extension_Optimizer*: Optimizers the node tree before compilation. +* *Twig_Extension_Optimizer*: Optimizes the node tree before compilation. The core, escaper, and optimizer extensions do not need to be added to the Twig environment, as they are registered by default. @@ -396,6 +396,7 @@ The ``core`` extension defines all the core features of Twig: * ``date`` * ``dump`` * ``random`` + * ``include`` * Tests: @@ -566,6 +567,20 @@ to enable by passing them to the constructor:: $twig->addExtension($optimizer); +Twig supports the following optimizations: + +* ``Twig_NodeVisitor_Optimizer::OPTIMIZE_ALL``, enables all optimizations +(this is the default value). +* ``Twig_NodeVisitor_Optimizer::OPTIMIZE_NONE``, disables all optimizations. +This reduces the compilation time, but it can increase the execution time +and the consumed memory. +* ``Twig_NodeVisitor_Optimizer::OPTIMIZE_FOR``, optimizes the ``for`` tag by +removing the ``loop`` variable creation whenever possible. +* ``Twig_NodeVisitor_Optimizer::OPTIMIZE_RAW_FILTER``, removes the ``raw`` +filter whenever possible. +* ``Twig_NodeVisitor_Optimizer::OPTIMIZE_VAR_ACCESS``, simplifies the creation +and access of variables in the compiled templates whenever possible. + Exceptions ---------- diff --git a/doc/intro.rst b/doc/intro.rst index 8f1d20a..57a4ca8 100644 --- a/doc/intro.rst +++ b/doc/intro.rst @@ -111,7 +111,7 @@ PHP code but only provides an optimized version of the .. tip:: - On Windows, you can also simply download and install a `pre-build DLL`_. + On Windows, you can also simply download and install a `pre-built DLL`_. Basic API Usage --------------- diff --git a/doc/recipes.rst b/doc/recipes.rst index 6ece40d..dfcc920 100644 --- a/doc/recipes.rst +++ b/doc/recipes.rst @@ -106,9 +106,10 @@ To change the block delimiters, you need to create your own lexer object:: $twig = new Twig_Environment(); $lexer = new Twig_Lexer($twig, array( - 'tag_comment' => array('{#', '#}'), - 'tag_block' => array('{%', '%}'), - 'tag_variable' => array('{{', '}}'), + 'tag_comment' => array('{#', '#}'), + 'tag_block' => array('{%', '%}'), + 'tag_variable' => array('{{', '}}'), + 'interpolation' => array('#{', '}'), )); $twig->setLexer($lexer); -- 1.7.2.5