blob: c078eef49e009b22db6a93785b14c8d7c59e1a3d [file] [log] [blame]
Matthias Andreas Benkard12a57352021-12-28 18:02:04 +01001``deprecated``
2==============
3
4Twig generates a deprecation notice (via a call to the ``trigger_error()``
5PHP function) where the ``deprecated`` tag is used in a template:
6
7.. code-block:: twig
8
9 {# base.twig #}
10 {% deprecated 'The "base.twig" template is deprecated, use "layout.twig" instead.' %}
11 {% extends 'layout.twig' %}
12
13Also you can deprecate a block in the following way:
14
15.. code-block:: twig
16
17 {% block hey %}
18 {% deprecated 'The "hey" block is deprecated, use "greet" instead.' %}
19 {{ block('greet') }}
20 {% endblock %}
21
22 {% block greet %}
23 Hey you!
24 {% endblock %}
25
26Note that by default, the deprecation notices are silenced and never displayed nor logged.
27See :ref:`deprecation-notices` to learn how to handle them.