From: Fabien Potencier Date: Fri, 31 Dec 2010 14:39:30 +0000 (+0100) Subject: removed references to old Twig versions in the doc X-Git-Url: http://git.silmor.de/gitweb/?a=commitdiff_plain;h=3cbcc1f47b5f6ca33098dca868e07558f59bff31;p=web%2Fkonrad%2Ftwig.git removed references to old Twig versions in the doc --- diff --git a/doc/api.rst b/doc/api.rst index 4feec59..2dcfb5a 100644 --- a/doc/api.rst +++ b/doc/api.rst @@ -34,11 +34,6 @@ that looks up the templates in the ``/path/to/templates/`` folder. Different loaders are available and you can also write your own if you want to load templates from a database or other resources. -.. caution:: - - Before Twig 0.9.3, the ``cache`` option did not exist, and the cache - directory was passed as a second argument of the loader. - .. note:: Notice that the second argument of the environment is an array of options. @@ -88,32 +83,21 @@ The following options are available: the ``auto_reload`` option, it will be determined automatically based on the ``debug`` value. -* ``strict_variables`` (new in Twig 0.9.7): If set to ``false``, Twig will - silently ignore invalid variables (variables and or attributes/methods that - do not exist) and replace them with a ``null`` value. When set to ``true``, - Twig throws an exception instead (default to ``false``). - -* ``autoescape`` (new in Twig 0.9.10): If set to ``true``, auto-escaping will - be enabled by default for all templates (default to ``true``). +* ``strict_variables``: If set to ``false``, Twig will silently ignore invalid + variables (variables and or attributes/methods that do not exist) and + replace them with a ``null`` value. When set to ``true``, Twig throws an + exception instead (default to ``false``). -* ``optimizations`` (new in Twig 0.9.10): A flag that indicates which - optimizations to apply (default to ``-1`` -- all optimizations are enabled; - set it to ``0`` to disable). +* ``autoescape``: If set to ``true``, auto-escaping will be enabled by default + for all templates (default to ``true``). -.. caution:: - - Before Twig 0.9.3, the ``cache`` and ``auto_reload`` options did not - exist. They were passed as a second and third arguments of the filesystem - loader respectively. +* ``optimizations``: A flag that indicates which optimizations to apply + (default to ``-1`` -- all optimizations are enabled; set it to ``0`` to + disable). Loaders ------- -.. caution:: - - This section describes the loaders as implemented in Twig version 0.9.4 - and above. - Loaders are responsible for loading templates from a resource such as the file system. @@ -239,8 +223,7 @@ Twig comes bundled with the following extensions: * *Twig_Extension_Sandbox*: Adds a sandbox mode to the default Twig environment, making it safe to evaluated untrusted code. -* *Twig_Extension_Optimizer*: Optimizers the node tree before compilation (as - of Twig 0.9.10). +* *Twig_Extension_Optimizer*: Optimizers 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. You can disable an @@ -351,8 +334,7 @@ You can also change the escaping mode locally by using the ``autoescape`` tag: The ``autoescape`` tag has no effect on included files. -The escaping rules are implemented as follows (it describes the behavior of -Twig 0.9.9 and above): +The escaping rules are implemented as follows: * Literals (integers, booleans, arrays, ...) used in the template directly as variables or filter arguments are never automatically escaped: @@ -459,8 +441,8 @@ the extension constructor:: $sandbox = new Twig_Extension_Sandbox($policy, true); -Optimizer Extension (as of Twig 0.9.10) -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Optimizer Extension +~~~~~~~~~~~~~~~~~~~ The ``optimizer`` extension optimizes the node tree before compilation:: diff --git a/doc/templates.rst b/doc/templates.rst index b3ae80c..d69462c 100644 --- a/doc/templates.rst +++ b/doc/templates.rst @@ -89,7 +89,7 @@ If a variable or attribute does not exist you will get back a ``null`` value * if not, and if ``foo`` is an object, check that ``bar`` is a valid method (even if ``bar`` is the constructor - use ``__construct()`` instead); * if not, and if ``foo`` is an object, check that ``getBar`` is a valid method; - * if not, and if ``foo`` is an object, check that ``isBar`` is a valid method (as of Twig 0.9.9); + * if not, and if ``foo`` is an object, check that ``isBar`` is a valid method; * if not, return a ``null`` value. ``foo['bar']`` on the other hand works mostly the same with the a small @@ -107,9 +107,9 @@ If a variable or attribute does not exist you will get back a ``null`` value Twig always references the following variables: -* ``_self``: references the current template (was ``self`` before 0.9.9); +* ``_self``: references the current template; * ``_context``: references the current context; -* ``_charset``: references the current charset (as of 0.9.9). +* ``_charset``: references the current charset. Filters ------- @@ -347,8 +347,8 @@ following constructs do the same: {% block title page_title|title %} -Dynamic Inheritance (as of Twig 0.9.7) -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Dynamic Inheritance +~~~~~~~~~~~~~~~~~~~ Twig supports dynamic inheritance by using a variable as the base template: @@ -365,8 +365,8 @@ the parent template:: $twig->display('template.twig', array('layout' => $layout)); -Conditional Inheritance (as of Twig 0.9.7) -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Conditional Inheritance +~~~~~~~~~~~~~~~~~~~~~~~ As a matter of fact, the template name can be any valid expression. So, it's also possible to make the inheritance mechanism conditional: @@ -485,7 +485,7 @@ provided in a variable called ``users``: ``Traversable`` interface. If you do need to iterate over a sequence of numbers, you can use the ``..`` -operator (as of Twig 0.9.5): +operator: .. code-block:: jinja @@ -539,7 +539,7 @@ Variable Description The ``loop.length``, ``loop.revindex``, ``loop.revindex0``, and ``loop.last`` variables are only available for PHP arrays, or objects that - implement the ``Countable`` interface (as of Twig 0.9.7). + implement the ``Countable`` interface. .. note:: @@ -581,11 +581,6 @@ You can also access both keys and values: {% endfor %} -.. note:: - - On Twig before 0.9.3, you need to use the ``items`` filter to access both - the keys and values (``{% for key, value in users|items %}``). - If ~~ @@ -749,8 +744,7 @@ the ``set`` tag and can have multiple targets: {% set foo, bar = 'foo', 'bar' %} -The ``set`` tag can also be used to 'capture' chunks of HTML (new in Twig -0.9.6): +The ``set`` tag can also be used to 'capture' chunks of HTML: .. code-block:: jinja @@ -811,11 +805,6 @@ You can disable access to the context by appending the ``only`` keyword: {# no variable will be accessible #} {% include 'foo' only %} -.. note:: - - The ``with`` keyword is supported as of Twig 0.9.5. The ``only`` keyword - is supported as of Twig 0.9.9. - .. tip:: When including a template created by an end user, you should consider @@ -949,13 +938,12 @@ exist: writing the number down. If a dot is present the number is a float, otherwise an integer. -* ``["foo", "bar"]`` (new in Twig 0.9.5): Arrays are defined by a sequence of - expressions separated by a comma (``,``) and wrapped with squared brackets - (``[]``). +* ``["foo", "bar"]``: Arrays are defined by a sequence of expressions + separated by a comma (``,``) and wrapped with squared brackets (``[]``). -* ``{"foo": "bar"}`` (new in Twig 0.9.10): Hashes are defined by a list of keys - and values separated by a comma (``,``) and wrapped with curly braces (``{}``). - A value can be any valid expression. +* ``{"foo": "bar"}``: Hashes are defined by a list of keys and values + separated by a comma (``,``) and wrapped with curly braces (``{}``). A value + can be any valid expression. * ``true`` / ``false``: ``true`` represents the true value, ``false`` represents the false value. @@ -1023,8 +1011,8 @@ Comparisons The following comparison operators are supported in any expression: ``==``, ``!=``, ``<``, ``>``, ``>=``, and ``<=``. -Containment Operator (new in Twig 0.9.5) -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Containment Operator +~~~~~~~~~~~~~~~~~~~~ The ``in`` operator performs containment test. @@ -1052,8 +1040,8 @@ To perform a negative test, use the ``not in`` operator: {# is equivalent to #} {% if not (1 in [1, 2, 3]) %} -Tests (new in Twig 0.9.9) -~~~~~~~~~~~~~~~~~~~~~~~~~ +Tests +~~~~~ The ``is`` operator performs tests. Tests can be used to test a variable against a common expression. The right operand is name of the test: @@ -1087,8 +1075,8 @@ Other Operators The following operators are very useful but don't fit into any of the other two categories: -* ``..`` (new in Twig 0.9.5): Creates a sequence based on the operand before - and after the operator (see the ``for`` tag for some usage examples). +* ``..``: Creates a sequence based on the operand before and after the + operator (see the ``for`` tag for some usage examples). * ``|``: Applies a filter. @@ -1136,8 +1124,8 @@ The ``format`` filter formats a given string by replacing the placeholders {# returns I like foo and bar. (if the foo parameter equals to the foo string) #} -``replace`` (new in Twig 0.9.9) -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +``replace`` +~~~~~~~~~~~ The ``replace`` filter formats a given string by replacing the placeholders (placeholders are free-form): @@ -1273,8 +1261,8 @@ the last filter applied to it. {{ var|raw }} {# var won't be escaped #} {% endautoescape %} -``merge`` (new in Twig 0.9.10) -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +``merge`` +~~~~~~~~~ The ``merge`` filter merges an array or a hash with the value: @@ -1286,8 +1274,8 @@ The ``merge`` filter merges an array or a hash with the value: {# items now contains { 'apple': 'fruit', 'orange': 'fruit', 'peugeot': 'car' } #} -List of built-in Tests (new in Twig 0.9.9) ------------------------------------------- +List of built-in Tests +---------------------- ``divisibleby`` ~~~~~~~~~~~~~~~