Opened 3 years ago

Closed 3 years ago

Last modified 3 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?


Attachments (0)

Change History (2)

comment:1 Changed 3 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 3 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 :/

Add Comment

Modify Ticket

Change Properties
<Author field>
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'

E-mail address and user name can be saved in the Preferences.

Note: See TracTickets for help on using tickets.