Problem/Motivation

spaceless tag has been removed in Twig 3. It is not used in Drupal 9 anymore.

Proposed resolution

Use spaceless filter instead in Drupal 8 too to help new sites become compatible with Twig 3 / Drupal 10.
https://twig.symfony.com/doc/3.x/filters/spaceless.html

Before:

{% spaceless %}

{% endspaceless %}

After:

{% apply spaceless %}

{% endapply %}

Remaining tasks

Create a patch.

User interface changes

None.

CommentFileSizeAuthor
#7 3094850-7.patch15.75 KBdinesh18
#3 3094850-3.patch1.5 KBdinesh18

Comments

Chi created an issue. See original summary.

dinesh18’s picture

Assigned: Unassigned » dinesh18
dinesh18’s picture

Status: Active » Needs review
StatusFileSize
new1.5 KB

@chi could you please check if it looks good. Done for only two template files.
If everything is okay, I will do it for the remaining templates.
Thank you

Status: Needs review » Needs work

The last submitted patch, 3: 3094850-3.patch, failed testing. View results

chi’s picture

Issue summary: View changes

@Dinesh18 you confused spaceless tag and spaceless filter. See updated issue summary.

chi’s picture

Version: 9.0.x-dev » 8.9.x-dev

Actually Drupal 9 does not use spacelessat all. However it still makes sense to fix this in 8.9.x to make templates compatible with Twig 2+ as developers tend to use core templates as a starting point.

dinesh18’s picture

Status: Needs work » Needs review
StatusFileSize
new15.75 KB

Here is the updated patch as per the new issue summary. Kindly review it

chi’s picture

Status: Needs review » Postponed

This should go after #3095099: Update Twig to 3.5.0.

chi’s picture

dinesh18’s picture

Status: Postponed » Needs review

documentation updated. Kindly review

chi’s picture

@Dinesh18 there are still a few references to spaceless tag on that page. I think the documentation needs be carefully revised and that does not have to be part of this ticket.

dinesh18’s picture

Status: Needs review » Needs work
dinesh18’s picture

Assigned: dinesh18 » Unassigned
chi’s picture

Status: Needs work » Postponed

Postponing per #8.

Version: 8.9.x-dev » 9.1.x-dev

Drupal 8.9.0-beta1 was released on March 20, 2020. 8.9.x is the final, long-term support (LTS) minor release of Drupal 8, which means new developments and disruptive changes should now be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 9.1.x-dev » 9.2.x-dev

Drupal 9.1.0-alpha1 will be released the week of October 19, 2020, which means new developments and disruptive changes should now be targeted for the 9.2.x-dev branch. For more information see the Drupal 9 minor version schedule and the Allowed changes during the Drupal 9 release cycle.

Version: 9.2.x-dev » 9.3.x-dev

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

gábor hojtsy’s picture

Version: 9.3.x-dev » 8.9.x-dev

This does not apply to Drupal 9, the spaceless tag is not used there. This is only to be done if we deem the updates to core templates are helpful for NEW Drupal 8 sites. Those would copy core templates to new custom templates. Existing Drupal 8 sites already have their templates, so core fixes would not help them. How many new Drupal 8 sites are created these days after almost a year of Drupal 9? I don't think too much.

gábor hojtsy’s picture

Issue summary: View changes
Issue tags: -Twig 3
Parent issue: #3094493: Upgrade to Twig 3 »

Removing the Twig 3 parent and slightly update the issue summary.

adamzimmermann’s picture

Hopefully this helps when this is resumed.

I have been using a Twig linter to fix this very issue in our custom codebases and have been happy with it so far.

I've also been trying to get some momentum behind an official Twig linting recommendation.

Version: 8.9.x-dev » 9.2.x-dev

Drupal 8 is end-of-life as of November 17, 2021. There will not be further changes made to Drupal 8. Bugfixes are now made to the 9.3.x and higher branches only. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.2.x-dev » 9.3.x-dev

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.15 was released on June 1st, 2022 and is the final full bugfix release for the Drupal 9.3.x series. Drupal 9.3.x will not receive any further development aside from security fixes. Drupal 9 bug reports should be targeted for the 9.4.x-dev branch from now on, and new development or disruptive changes should be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.9 was released on December 7, 2022 and is the final full bugfix release for the Drupal 9.4.x series. Drupal 9.4.x will not receive any further development aside from security fixes. Drupal 9 bug reports should be targeted for the 9.5.x-dev branch from now on, and new development or disruptive changes should be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

luke.leber’s picture

Status: Postponed » Closed (outdated)

I think this one can be safely closed out, as Drupal 9 is no more.