Opened 18 years ago

Closed 18 years ago

Last modified 17 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: dev
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: no UI/UX: no

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@…> 18 years ago.
Spaceless with optional numeric argument patch
reintroduce_space.diff (823 bytes ) - added by shugyoku 17 years ago.
Reintroduce spaces for anchor tags that enclose text

Download all attachments as: .zip

Change History (13)

comment:1 by Rob Hudson <treborhudson@…>, 18 years ago

Cc: treborhudson@… added

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 by Chris Beaven, 18 years ago

Triage Stage: UnreviewedAccepted

Sounds good, someone write up the patch.

by Rob Hudson <treborhudson@…>, 18 years ago

Attachment: spaceless.diff added

Spaceless with optional numeric argument patch

comment:3 by Rob Hudson <treborhudson@…>, 18 years ago

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 by ampaze@…, 18 years ago

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 by Manoj Govindan <egmanoj@…>, 18 years ago

Has patch: set

comment:6 by Chris Beaven, 18 years ago

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 by Rob Hudson <treborhudson@…>, 18 years ago

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 by Russell Keith-Magee, 18 years ago

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 by Russell Keith-Magee, 18 years ago

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 by anonymous, 17 years ago

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).

by shugyoku, 17 years ago

Attachment: reintroduce_space.diff added

Reintroduce spaces for anchor tags that enclose text

comment:11 by shugyoku, 17 years ago

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