Remove outdated "import _self as" tag

Created on 6 March 2023, almost 2 years ago
Updated 20 March 2023, over 1 year ago

Problem/Motivation

We have some outdated Twig1 code:

Branch 4.x:

templates/patterns/pagination/pattern-pagination.html.twig:{% import _self as pagination %}
templates/patterns/navbar/pattern-navbar.html.twig:  {% import _self as menus %}

Branch 5.x:

templates/patterns/navbar_nav/pattern-navbar-nav.html.twig:  {% import _self as menus %}
templates/patterns/pagination/pattern-pagination.html.twig:{% import _self as pagination %}

Since Twig 2, it is not necessary to import explicitly _self in variable :

{% macro item(whatever) %}...{% endmacro %}
{% import _self as pagination %}
{{ pagination.item(whatever) }}

Because it is now possible to call a macro directly from _self:

{% macro item(whatever) %}...{% endmacro %}
{{ _self.item(whatever) }}

Source : https://twig.symfony.com/doc/2.x/tags/macro.html

Proposed resolution

Remove "import _self as" tags

For 4.x, push directly the commit. For 5.x, do a MR.

API changes

None because:

📌 Task
Status

Fixed

Version

5.0

Component

Code

Created by

🇫🇷France pdureau Paris

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024