Twig

The flexible, fast, and secure
template engine for PHP

a Symfony Product
You are reading the documentation for Twig 2.x. Switch to the documentation for Twig 1.x. 3.x.

Questions & Feedback

License

Twig documentation is licensed under the new BSD license.

deprecatedΒΆ

New in version 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:

1
2
3
{# 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:

1
2
3
4
5
6
7
8
{% 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 Displaying Deprecation Notices to learn how to handle them.

Website powered by Symfony and Twig, deployed on
The Twig logo is © 2010-2020 Symfony