Opened 17 years ago

Closed 12 years ago

#4746 closed Cleanup/optimization (fixed)

[patch] Allow whitespace before and after filter separator

Reported by: sciyoshi@… Owned by: Aymeric Augustin
Component: Template system Version: dev
Severity: Normal Keywords: template filter separator whitespace tplrf-fixed
Cc: sciyoshi@… Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no


It always bugged me that I couldn't do {{ variable | filter }} because of the spaces around the pipe. It seems to me that this looks cleaner, although it may have been a design choice not to allow this.

Anyways, here's the patch.

Samuel Cormier-Iijima

Attachments (2)

filter_sep.patch (450 bytes ) - added by sciyoshi@… 17 years ago.
Patch to allow whitespace around template filter separators
4746.patch (1.7 KB ) - added by Aymeric Augustin 12 years ago.

Download all attachments as: .zip

Change History (12)

by sciyoshi@…, 17 years ago

Attachment: filter_sep.patch added

Patch to allow whitespace around template filter separators

comment:1 by Chris Beaven, 17 years ago

Needs tests: set
Triage Stage: UnreviewedDesign decision needed

comment:2 by miguel.filho@…, 17 years ago

I would like to support this change. Right now I'm a django starter and took some time for me to figure out that a simple space was getting my hair off my head. Although the documentation show the example without spaces, seeing the way filters work just give the same feeling of using a pipe in a shell script, with or without spaces.

comment:3 by Gary Wilson <gary.wilson@…>, 17 years ago

I'm not against allowing spaces, but we probably don't want to allow newlines.

comment:4 by honeyman, 17 years ago

Just my +1 to this feature (no voting in this ticket engine? would be nice to have). It is slightly inconsistent that Django site logic is written in Python where whitespaces in the code (do not confuse with indentation) do not matter, templates are written mostly in HTML where whitespaces do not alter the rendered output, but the whitespaces inside the filter declarations do matter.

comment:5 by Johannes Dollinger, 16 years ago

Keywords: tplrf-fixed added

This would be fixed by the refactoring proposed in #7806.

comment:6 by Malcolm Tredinnick, 14 years ago

Triage Stage: Design decision neededAccepted


comment:7 by Gabriel Hurley, 13 years ago

Severity: Normal
Type: Cleanup/optimization

comment:8 by Aymeric Augustin, 12 years ago

Easy pickings: unset
Owner: changed from nobody to Aymeric Augustin
UI/UX: unset

by Aymeric Augustin, 12 years ago

Attachment: 4746.patch added

comment:9 by Aymeric Augustin, 12 years ago

Needs tests: unset
Triage Stage: AcceptedReady for checkin

This is really a very simple change and it looks reasonable to me.

The current behavior (raising TemplateSyntaxError for spaces around the |) was tested. AFAICT this test exists mostly for completeness and it reasonable to change it if we make the filter syntax less strict.

This may be a sensitive design change. I'll leave the patch in RFC for a few days so that other core devs can get a chance to review or veto it.

comment:10 by Aymeric Augustin, 12 years ago

Resolution: fixed
Status: newclosed
Note: See TracTickets for help on using tickets.
Back to Top