Remove the warning about do tag?

Created on 27 January 2025, 2 months ago

Problem/Motivation

Today, we raise a "Careful with do usage." warning when we found a do tag:

{% do attributes.setAttribute('checked', true) %}

This rule comes from the believing than Twig operation must be immutable (see #3296456: Twig attribute setter methods are not immutable ).

However, I was challenged about this by @johnalbin in https://drupal.slack.com/archives/C06GX5T33/p1734340998899739

Surely the {% do %} in Twig means “do something mutable” since there’s no point in doing something immutable that is also not printed?

Proposed resolution

do tag seems legit and exists also in https://jinja.palletsprojects.com/en/stable/templates/#expression-statement and https://docs.rs/minijinja/latest/minijinja/syntax/index.html#-do-

So, I would advice to remove the warning. What do you think ?

📌 Task
Status

Active

Version

1.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

Production build 0.71.5 2024