Opened 10 years ago

Closed 10 years ago

Last modified 8 years ago

#3532 closed (fixed)

Give the template tag "spaceless" an option wether to leave a single space or none.

Reported by: ampaze@… Owned by: Adrian Holovaty
Component: Template system Version: master
Severity: Keywords: spaceless template tag
Cc: treborhudson@… Triage Stage: Design decision needed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

As I am having CSS trouble with IE, I need to have absolutely no whitechars between list elements.

{% spaceless %} seems to be the way to go. And while it removes all the
whitespaces, it puts a single space back, for convenience i guess.

I think this means to either extend the spaceless tag to be able to choose
what to do or make a new one?

Attachments (2)

spaceless.diff (5.0 KB) - added by Rob Hudson <treborhudson@…> 10 years ago.
Spaceless with optional numeric argument patch
reintroduce_space.diff (823 bytes) - added by shugyoku 8 years ago.
Reintroduce spaces for anchor tags that enclose text

Download all attachments as: .zip

Change History (13)

comment:1 Changed 10 years ago by Rob Hudson <treborhudson@…>

Cc: treborhudson@… added
Needs documentation: unset
Needs tests: unset
Patch needs improvement: unset

I agree... when I first used this I expected no spaces (in other words: spaceless). I too would like a "no I really mean spaceless" templatetag.

Perhaps spaceless should be renamed to normalize or something?

Or change the templatetag to accept an optional numeric value for the number of spaces to put back with the default being 1? ie: {% spaceless 0 %}{% endspaceless %}

comment:2 Changed 10 years ago by Chris Beaven

Triage Stage: UnreviewedAccepted

Sounds good, someone write up the patch.

Changed 10 years ago by Rob Hudson <treborhudson@…>

Attachment: spaceless.diff added

Spaceless with optional numeric argument patch

comment:3 Changed 10 years ago by Rob Hudson <treborhudson@…>

I was about to code the patch to add spaces if none existed, but since this wasn't there before, I decided not to.

Would it be worth considering, that if the numeric value is > 0, to add spaces between tags if none existed prior? This would have the benefit that all spaces are uniform. It should be as simple as changing the \s+ to a \s*? in the regex, but I'm not convinced this is the best way to go.

comment:4 Changed 10 years ago by ampaze@…

Nice work! In my opinion {% spaceless %} should not add spaces, if there weren't any in the first place.

Btw. I think that the actual number of spaces added, is actually not that important, as multiple spaces will be shown as one by the browser anyway.

comment:5 Changed 10 years ago by Manoj Govindan <egmanoj@…>

Has patch: set

comment:6 Changed 10 years ago by Chris Beaven

Triage Stage: AcceptedReady for checkin

Thanks Rob

If we worry about adding spaces to tags it's a slight change in current functionality. For now let's stick with this. Like ampaze says it probably doesn't really matter about how many spaces. So maybe having a numeric value is a wee bit overkill but it solves the problem so I'm marking as ready.

comment:7 Changed 10 years ago by Rob Hudson <treborhudson@…>

Personally, I think the default should be no spaces, with an option to add spaces. Would there be objections to that? Or does that break BC?

comment:8 Changed 10 years ago by Russell Keith-Magee

Triage Stage: Ready for checkinDesign decision needed

I'm inclined to agree on the 'spaceless should mean spaceless' issue. I'm moving this discussion to the dev list so we can get an offical pronouncement on whether backwards compatibility is worth maintaining here.

comment:9 Changed 10 years ago by Russell Keith-Magee

Resolution: fixed
Status: newclosed

(In [4885]) Fixed #3532 -- Made spaceless template tag remove all spaces, rather than preserving a single space. Thanks for the suggestion, ampaze@….

comment:10 Changed 9 years ago by anonymous

This change broke my site, of course, as it undid the change described here: #1227 :-(

Guess I have to roll my own spaceless filter so I get something I can trust (it would be nice with one that understands PRE tags anyway).

Changed 8 years ago by shugyoku

Attachment: reintroduce_space.diff added

Reintroduce spaces for anchor tags that enclose text

comment:11 Changed 8 years ago by shugyoku

For others who need to, this patch can help reintroduce spaces between anchor tags that enclose text (ilke the example in #1227).

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