Opened 4 years ago

Closed 4 years ago

Last modified 4 years ago

#16415 closed New feature (invalid)

Template block function to strip whitespace from specific chunks

Reported by: foxwhisper Owned by: nobody
Component: Template system Version: 1.3
Severity: Normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no


Take the following example:

<div class="PostBlock
     {% if forloop.last %}Last{% endif %}
     {% if forloop.first %}
     {% else %}
        {% if not forloop.counter|divisibleby:"2" %}
        {% endif %}
     {% endif %}

That would be outputted in a horrible format. Instead, it would be nice to wrap it in something like {% no_whitespace %} {% end_no_whitespace %}, which would in turn strip all whitespace from the beginning and the end.

Any thoughts?


Change History (2)

comment:1 Changed 4 years ago by russellm

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Resolution set to invalid
  • Status changed from new to closed

Is there something wrong with {% spaceless %}?

comment:2 Changed 4 years ago by foxwhisper

Omg, how the hell did I miss that, I spent a good 20 minutes looking around for a solution on djangodocs and google.

Really sorry :/

Note: See TracTickets for help on using tickets.
Back to Top