Deprecate the spaceless filter#4236
Conversation
stof
left a comment
There was a problem hiding this comment.
This filter should be marked as deprecated in the filter definition, so that using the filter reports the deprecation at compile time (and so that the linter also reports it)
0660869 to
6f4be01
Compare
6f4be01 to
9fd4c48
Compare
better performance, etc. twigphp/Twig#4236
|
I didn't find any good examples of how to replace {% apply spaceless %}
<span>1</span>
<span>2</span>
<span>3</span>
{% endapply %}To rewrite this without spaceless, I used <span>1</span>{{ null -}}
<span>2</span>{{ null -}}
<span>3</span>I experimented with other "null" conditions, and the following also work: Not sure if there is a better syntax to handle this? It might be worth adding this example to the docs? |
|
@ttk the shortest solution (and most efficient by disappearing entirely at runtime) is to use a comment to hold the whitespace control: |
Closes #3576
Deprecate the
spacelessfilter for the following reasons:{{ }}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.