spacey
The spacey filter protects whitespace between tags, so the spaceless filter won't remove it.
Any sequence of whitespace characters between two tags will be transformed into a single, normal (but HTML encoded) space.
This is useful when you have a text with several inline tags in sequence, in an otherwise spaceless code block.
Without spacey
{% set sentence =
'<em>This</em>
<strong>sentence</strong> has
<a href="#">five</a> <em>words</em>.'
%}
{% apply spaceless %}
<div>
<p>
{{sentence|raw}}
</p>
</div>
{% endapply %}
{# Outputs:
<div><p><em>This</em><strong>sentence</strong> has
<a href="#">five</a><em>words</em>.
</p></div>
#}
The above sentence will render in a web browser as:
Thissentence has fivewords.
With spacey
{% set sentence =
'<em>This</em>
<strong>sentence</strong> has
<a href="#">five</a> <em>words</em>.'
%}
{% apply spaceless %}
<div>
<p>
{{sentence|spacey|raw}}
</p>
</div>
{% endapply %}
{# Outputs:
<div><p><em>This</em>\ <strong>sentence</strong> has
<a href="#">five</a>\ <em>words</em>.
</p></div>
#}
The above sentence will render in a web browser as:
This sentence has five words.
Last updated
Was this helpful?