Skip to content

Commit

Permalink
updated the docs for 3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
fabpot committed Apr 23, 2019
1 parent 273b666 commit 682a271
Show file tree
Hide file tree
Showing 17 changed files with 9 additions and 204 deletions.
7 changes: 2 additions & 5 deletions doc/advanced.rst
Original file line number Diff line number Diff line change
Expand Up @@ -359,9 +359,6 @@ The ``node`` sub-node will contain an expression of ``my_value``. Node-based
tests also have access to the ``arguments`` node. This node will contain the
various other arguments that have been provided to your test.

.. versionadded:: 2.6
Dynamic tests support was added in Twig 2.6.

If you want to pass a variable number of positional or named arguments to the
test, set the ``is_variadic`` option to ``true``. Tests support dynamic
names (see dynamic filters and functions for the syntax).
Expand Down Expand Up @@ -955,5 +952,5 @@ Testing the node visitors can be complex, so extend your test cases from
`tests/Twig/Node`_ directory.

.. _`rot13`: https://secure.php.net/manual/en/function.str-rot13.php
.. _`tests/Twig/Fixtures`: https://github.com/twigphp/Twig/tree/2.x/test/Twig/Tests/Fixtures
.. _`tests/Twig/Node`: https://github.com/twigphp/Twig/tree/2.x/test/Twig/Tests/Node
.. _`tests/Twig/Fixtures`: https://github.com/twigphp/Twig/tree/3.x/test/Twig/Tests/Fixtures
.. _`tests/Twig/Node`: https://github.com/twigphp/Twig/tree/3.x/test/Twig/Tests/Node
5 changes: 0 additions & 5 deletions doc/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,6 @@ The following options are available:

The charset used by the templates.

* ``base_template_class`` *string* (defaults to ``\Twig\Template``)

The base template class to use for generated
templates.

* ``cache`` *string* or ``false``

An absolute path where to store the compiled templates, or
Expand Down
93 changes: 2 additions & 91 deletions doc/deprecated.rst
Original file line number Diff line number Diff line change
@@ -1,95 +1,6 @@
Deprecated Features
===================

This document lists deprecated features in Twig 2.x. Deprecated features are
This document lists deprecated features in Twig 3.x. Deprecated features are
kept for backward compatibility and removed in the next major release (a
feature that was deprecated in Twig 2.x is removed in Twig 3.0).

PSR-0
-----

* PSR-0 classes are deprecated in favor of namespaced ones since Twig 2.7.

Inheritance
-----------

* Defining a "block" definition in a non-capturing block in a child template is
deprecated since Twig 2.5.0. In Twig 3.0, it will throw a
``Twig\Error\SyntaxError`` exception. It does not work anyway, so most
projects won't need to do anything to upgrade.

Errors
------

* Passing a string as the ``$source`` argument on ``\Twig\Error\Error`` /
``Twig\Error\Error`` constructor is deprecated since Twig 2.6.1. Pass an
instance of ``Twig\Source`` instead.

Tags
----

* The ``spaceless`` tag is deprecated in Twig 2.7. Use the ``spaceless`` filter
instead or ``{% filter spaceless %}`` (the ``Twig\Node\SpacelessNode`` and
``Twig\TokenParser\SpacelessTokenParser`` classes are also deprecated).

* Using the ``spaceless`` tag at the root level of a child template is
deprecated in Twig 2.5.0. This does not work as one would expect it to work
anyway. In Twig 3.0, it will throw a ``Twig\Error\SyntaxError`` exception.

Final Classes
-------------

The following classes are marked as ``@final`` in Twig 2 and will be final in
3.0:

* ``Twig\Node\ModuleNode``
* ``Twig\TwigFilter``
* ``Twig\TwigFunction``
* ``Twig\TwigTest``
* ``Twig\Profiler\Profile``

Parser
------

* As of Twig 2.7, the ``\Twig\Parser::isReservedMacroName()`` / ``Twig\Parser``
function is deprecated and will be removed in Twig 3.0. It always returns
``false`` anyway as Twig 2 does not have any reserved macro names.

Environment
-----------

* As of Twig 2.7, the ``base_template_class`` option on ``Twig\Environment`` is
deprecated and will be removed in Twig 3.0.

* As of Twig 2.7, the ``Twig\Environment::getBaseTemplateClass()`` and
``Twig\Environment::setBaseTemplateClass()`` methods are deprecated and will
be removed in Twig 3.0.

* As of Twig 2.7, the ``Twig\Environment::getTemplateClass()`` is marked as
being internal and should not be used.

* As of Twig 2.7, passing a ``Twig\Template`` instance to the
``Twig\Environment::load()`` and ``Twig\Environment::resolveTemplate()`` is
deprecated.

* Depending on the input, ``Twig\Environment::resolveTemplate()`` can return
a ``Twig\Template`` or a ``Twig\TemplateWrapper`` instance. In Twig 3.0, this
method will **always** return a ``Twig\TemplateWrapper`` instance. You should
only rely on the methods of this class if you want to be forward-compatible.

Interfaces
----------

* As of Twig 2.7, the empty ``Twig\Loader\ExistsLoaderInterface`` interface is
deprecated and will be removed in Twig 3.0.

* As of Twig 2.7, the ``Twig\Extension\InitRuntimeInterface`` interface is
deprecated and will be removed in Twig 3.0.

Miscellaneous
-------------

* As of Twig 2.7, the ``Twig_SimpleFilter``, ``Twig_SimpleFunction``, and
``Twig_SimpleTest`` empty classes are deprecated and will be removed in Twig
3.0. Use ``Twig\TwigFilter``, ``Twig\TwigFunction``, and ``Twig\TwigTest``
respectively.
feature that was deprecated in Twig 3.x is removed in Twig 4.0).
3 changes: 0 additions & 3 deletions doc/filters/column.rst
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
``column``
==========

.. versionadded:: 2.8
The ``column`` filter was added in Twig 2.8.

The ``column`` filter returns the values from a single column in the input
array.

Expand Down
3 changes: 0 additions & 3 deletions doc/filters/join.rst
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
``join``
========

.. versionadded:: 2.6.1
The ``and`` argument was added in Twig 2.6.1.

The ``join`` filter returns a string which is the concatenation of the items
of a sequence:

Expand Down
4 changes: 0 additions & 4 deletions doc/filters/length.rst
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
``length``
==========

.. versionadded:: 2.3

Support for the ``__toString()`` magic method has been added in Twig 2.3.

The ``length`` filter returns the number of items of a sequence or mapping, or
the length of a string.

Expand Down
26 changes: 0 additions & 26 deletions doc/filters/raw.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,29 +10,3 @@ if ``raw`` is the last filter applied to it:
{% autoescape %}
{{ var|raw }} {# var won't be escaped #}
{% endautoescape %}
.. note::

**This note only applies to Twig before versions 1.39 and 2.8**.

Be careful when using the ``raw`` filter inside expressions:

.. code-block:: jinja
{% autoescape %}
{% set hello = '<strong>Hello</strong>' %}
{% set hola = '<strong>Hola</strong>' %}
{{ false ? '<strong>Hola</strong>' : hello|raw }}
does not render the same as
{{ false ? hola : hello|raw }}
but renders the same as
{{ (false ? hola : hello)|raw }}
{% endautoescape %}
The first ternary statement is not escaped: ``hello`` is marked as being
safe and Twig does not escape static values (see
:doc:`escape<../tags/autoescape>`). In the second ternary statement, even
if ``hello`` is marked as safe, ``hola`` remains unsafe and so is the whole
expression. The third ternary statement is marked as safe and the result is
not escaped.
4 changes: 0 additions & 4 deletions doc/filters/spaceless.rst
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
``spaceless``
=============

.. versionadded:: 1.38

The ``spaceless`` filter was added in Twig 1.38.

Use the ``spaceless`` filter to remove whitespace *between HTML tags*, not
whitespace within HTML tags or whitespace in plain text:

Expand Down
3 changes: 0 additions & 3 deletions doc/functions/random.rst
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
``random``
==========

.. versionadded:: 2.7
The "max" argument was added in Twig 2.7.

The ``random`` function returns a random value depending on the supplied
parameter type:

Expand Down
3 changes: 0 additions & 3 deletions doc/functions/template_from_string.rst
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
``template_from_string``
========================

.. versionadded:: 2.8
The name argument was added in Twig 2.8.

The ``template_from_string`` function loads a template from a string:

.. code-block:: jinja
Expand Down
2 changes: 1 addition & 1 deletion doc/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ Install `Composer`_ and run the following command to get the latest version:

.. code-block:: bash
composer require "twig/twig:^2.0"
composer require "twig/twig:^3.0"
.. _`Composer`: https://getcomposer.org/download/
4 changes: 2 additions & 2 deletions doc/intro.rst
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ Slim, Yii, Laravel, Codeigniter and Kohana — just to name a few.
Prerequisites
-------------

Twig needs at least **PHP 7.0.0** to run.
Twig needs at least **PHP 7.2.0** to run.

Installation
------------
Expand All @@ -37,7 +37,7 @@ The recommended way to install Twig is via Composer:

.. code-block:: bash
composer require "twig/twig:^2.0"
composer require "twig/twig:^3.0"
Basic API Usage
---------------
Expand Down
3 changes: 0 additions & 3 deletions doc/tags/deprecated.rst
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
``deprecated``
==============

.. versionadded:: 2.6
The ``deprecated`` tag was added in Twig 2.6.

Twig generates a deprecation notice (via a call to the ``trigger_error()``
PHP function) where the ``deprecated`` tag is used in a template:

Expand Down
5 changes: 2 additions & 3 deletions doc/tags/include.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,8 @@ of that file:
.. note::

As of Twig 1.12, it is recommended to use the
:doc:`include<../functions/include>` function instead as it provides the
same features with a bit more flexibility:
It is recommended to use the :doc:`include<../functions/include>` function
instead as it provides the same features with a bit more flexibility:

* The ``include`` function is semantically more "correct" (including a
template outputs its rendered contents in the current scope; a tag should
Expand Down
41 changes: 0 additions & 41 deletions doc/tags/spaceless.rst

This file was deleted.

3 changes: 0 additions & 3 deletions doc/templates.rst
Original file line number Diff line number Diff line change
Expand Up @@ -825,9 +825,6 @@ inserted into the string:
Whitespace Control
------------------

.. versionadded:: 2.8
Tag level Line whitespace control was added in Twig 2.8.

The first newline after a template tag is removed automatically (like in PHP).
Whitespace is not further modified by the template engine, so each whitespace
(spaces, tabs, newlines etc.) is returned unchanged.
Expand Down
4 changes: 0 additions & 4 deletions doc/tests/empty.rst
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
``empty``
=========

.. versionadded:: 2.3

Support for the ``__toString()`` magic method has been added in Twig 2.3.

``empty`` checks if a variable is an empty string, an empty array, an empty
hash, exactly ``false``, or exactly ``null``.

Expand Down

0 comments on commit 682a271

Please sign in to comment.