Django

Code

Ticket #1227 (closed: fixed)

Opened 3 years ago

Last modified 3 years ago

Problem with spaceless

Reported by: Simon Willison Assigned to: adrian
Milestone: Component: Template system
Version: Keywords:
Cc: Triage Stage: Unreviewed
Has patch: 0 Needs documentation: 0
Needs tests: 0 Patch needs improvement: 0

Description

The new spaceless tag introduced in [1968] is over-zealous. Consider the following example (taken from metafilter, where it is a common idiom):

<a href="http://www.carm.org/questions/rock.htm">Can God</a> <a href="http://www.str.org/site/News2?page=NewsArticle&id=5160">make a rock</a> <a href="http://www.godandscience.org/apologetics/rock.html">so heavy</a> <a href="http://www.simpsoncrazy.com/information/scripts/dabf11.shtml">that he</a> <a href="http://geocities.com/cangodmakearock">could not</a> <a href="http://www.askmoses.com/qa_detail.html?h=419&o=237">lift it?</a>

The spaceless tag would remove the spaces between these links entirely, causing them to look like this:

CanGodmakearocksoheavythathecouldnotliftit??

The solution is to replace multiple whitespace with a single space rather than removing them entirely. A more complex solution would be to remove ALL whitespace between block-level tags but leave space beteween inline tags, but the complexity and performance overhead of doing this probably prohibits it.

Attachments

Change History

01/14/06 23:18:18 changed by adrian

  • status changed from new to closed.
  • resolution set to fixed.

(In [1969]) Fixed #1227 -- Fixed problem with new {% spaceless %} tag. It now normalizes spaces to a single space rather than no spaces


Add/Change #1227 (Problem with spaceless)




Change Properties
Action