Fabien Potencier 98a8210e25 feature #4236 Deprecate the spaceless filter (fabpot)
This PR was merged into the 3.x branch.

Discussion
----------

Deprecate the spaceless filter

Closes #3576

Deprecate the `spaceless` filter for the following reasons:

* The performance is bad (as the work is done at runtime via a regexp)
* Optimizing the size of an HTML doc server side is "almost never" a good idea (compression is better and enough)
* There are some edge cases where you want to keep some spaces (see #3576)
* Controlling whitespace is possible and fine-grained via the dedicated Twig modifiers on `{{ }}`

If someone find it useful, re-creating it is trivial (`return trim(preg_replace('/>\s+</', '><', $content ?? ''));`),
but with so many caveats and not so many use cases, I think it does not belong to core.

Commits
-------

9fd4c487 Deprecate the spaceless filter
2024-08-26 17:00:09 +02:00
2024-08-10 12:32:24 +02:00
2024-08-26 16:25:20 +02:00
2024-08-18 19:25:19 +02:00
2024-08-26 16:25:20 +02:00
2024-08-26 16:25:20 +02:00
2024-08-26 16:25:20 +02:00
2024-08-10 12:32:24 +02:00

Twig, the flexible, fast, and secure template language for PHP
==============================================================

Twig is a template language for PHP.

Twig uses a syntax similar to the Django and Jinja template languages which
inspired the Twig runtime environment.

Sponsors
--------

.. raw:: html

    <a href="https://docs.blackfire.io/introduction?utm_source=twig&utm_medium=github_readme&utm_campaign=logo">
        <img src="https://static.blackfire.io/assets/intemporals/logo/png/blackfire-io_secondary_horizontal_transparent.png?1" width="255px" alt="Blackfire.io">
    </a>

More Information
----------------

Read the `documentation`_ for more information.

.. _documentation: https://twig.symfony.com/documentation
Languages
PHP 99.9%