Fixes and minor additions to the docs.

This commit is contained in:
Javier Eguiluz
2013-01-31 09:30:58 +01:00
parent eaadcca54b
commit aac6cb613c
3 changed files with 22 additions and 6 deletions
+17 -2
View File
@@ -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
----------
+1 -1
View File
@@ -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
---------------
+4 -3
View File
@@ -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);