Matthias Andreas Benkard | 12a5735 | 2021-12-28 18:02:04 +0100 | [diff] [blame^] | 1 | ``deprecated`` |
| 2 | ============== |
| 3 | |
| 4 | Twig generates a deprecation notice (via a call to the ``trigger_error()`` |
| 5 | PHP 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 | |
| 13 | Also 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 | |
| 26 | Note that by default, the deprecation notices are silenced and never displayed nor logged. |
| 27 | See :ref:`deprecation-notices` to learn how to handle them. |