Opened 9 years ago

Closed 4 years ago

#4746 closed Cleanup/optimization (fixed)

[patch] Allow whitespace before and after filter separator

Reported by: sciyoshi@… Owned by: aaugustin
Component: Template system Version: master
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@… 9 years ago.
Patch to allow whitespace around template filter separators
4746.patch (1.7 KB) - added by aaugustin 4 years ago.

Download all attachments as: .zip

Change History (12)

Changed 9 years ago by sciyoshi@…

Patch to allow whitespace around template filter separators

comment:1 Changed 9 years ago by SmileyChris

  • Needs documentation unset
  • Needs tests set
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to Design decision needed

comment:2 Changed 9 years ago by miguel.filho@…

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 Changed 9 years ago by Gary Wilson <gary.wilson@…>

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

comment:4 Changed 9 years ago by honeyman

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 Changed 8 years ago by emulbreh

  • Keywords tplrf-fixed added

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

comment:6 Changed 6 years ago by mtredinnick

  • Triage Stage changed from Design decision needed to Accepted


comment:7 Changed 5 years ago by gabrielhurley

  • Severity set to Normal
  • Type set to Cleanup/optimization

comment:8 Changed 5 years ago by aaugustin

  • Easy pickings unset
  • Owner changed from nobody to aaugustin
  • UI/UX unset

Changed 4 years ago by aaugustin

comment:9 Changed 4 years ago by aaugustin

  • Needs tests unset
  • Triage Stage changed from Accepted to Ready 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 Changed 4 years ago by aaugustin

  • Resolution set to fixed
  • Status changed from new to closed
Note: See TracTickets for help on using tickets.
Back to Top