Opened 14 years ago
Closed 14 years ago
#15798 closed Cleanup/optimization (wontfix)
"spaceless" filter does not not honor <pre> tag formatting
Reported by: | dfcode | Owned by: | nobody |
---|---|---|---|
Component: | Template system | Version: | 1.3 |
Severity: | Normal | Keywords: | spaceless, html, pre |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
I have a blog site where I occasionally wrap some HTML code between <PRE> tags to put it on display for my viewers. I've noticed that when I apply the {% spaceless %} filter to my document, Django plows straight through the embedded HTML code with no regard for the "pre-formatted" declaration. An example might be:
<html> <body> <pre> <form> <label>This is an example of some code I want to display in indented form.</label> <input type="submit" /> </form> </pre> </body> </html>
results in:
<html><body><pre><form><label>This is an example of some code I want to display in indented form.</label><input type="submit" /></form></pre></body></html>
and one line of code is displayed on my webpage.
Perhaps this is intentional. If not, I think the 'spaceless' filter should be programmed to recognize <pre> tags and leave the content within them alone.
Change History (1)
comment:1 by , 14 years ago
Easy pickings: | unset |
---|---|
Resolution: | → wontfix |
Status: | new → closed |
Currently the {% spaceless %} tag does what is documented: it removes all spaces.
#8123 discusses customizing its behavior for certain tags (inline vs. block); it was rejected by two core developers. The bottom line is that if you do not want to remove all spaces, you just shouldn't use {% spaceless %}.
In my opinion, the behavior is intentional, so I will close the ticket as wontfix.
PS1 : your idea was briefly mentioned here: http://code.djangoproject.com/ticket/3532#comment:10 but not discussed further.
PS2 : for the record, here is the history of the {% spaceless %} tag: