Code

Opened 5 years ago

Closed 5 years ago

#11717 closed (duplicate)

concat default template filter

Reported by: zanuxzan Owned by: nobody
Component: Uncategorized Version: 1.1
Severity: Keywords: concat templatetags filters
Cc: Triage Stage: Unreviewed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

It would be really nice to be able to concat variables or strings together within a template so that the concat'd values can be then sent into another filter. This can be done using stringformat however its not exactly that pretty and possibly prone to problems. For example:

?next={{ object.get_absolute_url|stringformat:'s#add-comment'|urlencode }}

The included patch for the file source:django/trunk/django/template/defaultfilters.py allows the following to be performed:

?next={{ object.get_absolute_url|concat:'#add-comment'|urlencode }}

I am sure that I would not be the first person to have this problem, so if there is a better solution I would be happy to hear it.

Attachments (1)

patch-11717.diff (1.1 KB) - added by zanuxzan 5 years ago.
concat template tag.

Download all attachments as: .zip

Change History (3)

Changed 5 years ago by zanuxzan

concat template tag.

comment:1 Changed 5 years ago by dc

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

See also #11687 which proposes to make 'add' filter more versatile.

comment:2 Changed 5 years ago by dc

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

Duplicate of #8088

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.