Skip to content

Commit

Permalink
minor #4308 [Doc] Provide an alternative for the deprecated spaceless…
Browse files Browse the repository at this point in the history
… filter (javiereguiluz, fabpot)

This PR was merged into the 3.x branch.

Discussion
----------

[Doc] Provide an alternative for the deprecated spaceless filter

When a feature is deprecated, it's recommended to provide an alternative for it (or mention that there's no alternative).

So, let's mention the whitespace control features in the deprecation message of the `spaceless` filter.

Commits
-------

5a94ddc Suggest wording
b5d19ee [Doc] Provide an alternative for the deprecated spaceless filter
  • Loading branch information
fabpot committed Sep 14, 2024
2 parents 1b9df76 + 5a94ddc commit 03f695f
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 16 deletions.
3 changes: 2 additions & 1 deletion doc/filters/spaceless.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@

.. warning::

The ``spaceless`` filter is deprecated as of Twig 3.12.
The ``spaceless`` filter is deprecated as of Twig 3.12. While not a full
replacement, you can check the :ref:`whitespace control features <templates-whitespace-control>`.

Use the ``spaceless`` filter to remove whitespace *between HTML tags*, not
whitespace within HTML tags or whitespace in plain text:
Expand Down
15 changes: 0 additions & 15 deletions doc/templates.rst
Original file line number Diff line number Diff line change
Expand Up @@ -959,21 +959,6 @@ the modifiers on one side of a tag or on both sides:
{{~ value }} </li>
{# outputs '<li>\nno spaces </li>' #}

.. tip::

In addition to the whitespace modifiers, Twig also has a ``spaceless`` filter
that removes whitespace **between HTML tags**:

.. code-block:: html+twig

{% apply spaceless %}
<div>
<strong>foo bar</strong>
</div>
{% endapply %}

{# output will be <div><strong>foo bar</strong></div> #}

Extensions
----------

Expand Down

0 comments on commit 03f695f

Please sign in to comment.