File: deprecated.rst

package info (click to toggle)
php-twig 2.14.3-1%2Bdeb11u2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 5,240 kB
  • sloc: php: 18,830; makefile: 215; sh: 42; python: 33
file content (31 lines) | stat: -rw-r--r-- 846 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
``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:

.. code-block:: twig

    {# base.twig #}
    {% deprecated 'The "base.twig" template is deprecated, use "layout.twig" instead.' %}
    {% extends 'layout.twig' %}

Also you can deprecate a block in the following way:

.. code-block:: twig

    {% block hey %}
        {% deprecated 'The "hey" block is deprecated, use "greet" instead.' %}
        {{ block('greet') }}
    {% endblock %}

    {% block greet %}
        Hey you!
    {% endblock %}

Note that by default, the deprecation notices are silenced and never displayed nor logged.
See :ref:`deprecation-notices` to learn how to handle them.