Code

Opened 7 years ago

Closed 2 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

Description

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@… 7 years ago.
Patch to allow whitespace around template filter separators
4746.patch (1.7 KB) - added by aaugustin 2 years ago.

Download all attachments as: .zip

Change History (12)

Changed 7 years ago by sciyoshi@…

Patch to allow whitespace around template filter separators

comment:1 Changed 7 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 7 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 http://www.djangoproject.com/documentation/templates/#filters 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 7 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 7 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 6 years ago by emulbreh

  • Keywords tplrf-fixed added

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

comment:6 Changed 4 years ago by mtredinnick

  • Triage Stage changed from Design decision needed to Accepted

Accepted.

comment:7 Changed 3 years ago by gabrielhurley

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

comment:8 Changed 2 years ago by aaugustin

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

Changed 2 years ago by aaugustin

comment:9 Changed 2 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 2 years ago by aaugustin

  • Resolution set to fixed
  • Status changed from new to closed

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.