Opened 5 years ago

Closed 5 years ago

Last modified 5 years ago

#16415 closed New feature (invalid)

Template block function to strip whitespace from specific chunks

Reported by: Cal Leeming 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

Description

Take the following example:

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

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?

Cal

Change History (2)

comment:1 Changed 5 years ago by Russell Keith-Magee

Needs documentation: unset
Needs tests: unset
Patch needs improvement: unset
Resolution: invalid
Status: newclosed

Is there something wrong with {% spaceless %}?

comment:2 Changed 5 years ago by Cal Leeming

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