spaceless Tag

Coding

Documentation

Removes irrelevant whitespace between HTML tags.

Template

{% spaceless %}
<p>
  <small class="text-muted">
    Created on: {{ joke.created }}
    Last updated: {{ joke.updated }}
  </small>
</p>
{% endspaceless %}

Result

<p><small class="text-muted">
    Created on: 
    Last updated: 
  </small></p>

Notice that the whitespace within the small element has not been removed. Only whitespace between successive opening tags and successive closing tags is removed.


Did we get something wrong? Is there a use case for the spaceless tag that we should add? Please let us know.

Send Feedback

Official Documentation
This page last updated on Sept. 16, 2020, 7:33 p.m. EST