Opened 5 years ago

Closed 4 years ago

#12847 closed New feature (fixed)

Allow simple_tags to specify a function name

Reported by: dcramer Owned by: vladmos
Component: Template system Version: 1.1
Severity: Normal Keywords:
Cc: 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 would be useful if simple_tag allowed you to specify the function name.

e.g.

register.simple_tag(lambda x: x-1, 'minusone')

Attachments (2)

renamed_simple_tags.patch (3.0 KB) - added by vladmos 4 years ago.
renamed_simple_tags.2.patch (4.2 KB) - added by vladmos 4 years ago.

Download all attachments as: .zip

Change History (9)

comment:1 Changed 5 years ago by SmileyChris

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to Accepted

It'd also be useful for if you want the simple tag to have a different name than the actual function name.

comment:2 Changed 4 years ago by lukeplant

  • Type set to New feature

comment:3 Changed 4 years ago by lukeplant

  • Severity set to Normal

comment:4 Changed 4 years ago by vladmos

  • Easy pickings unset
  • Owner changed from nobody to vladmos
  • Status changed from new to assigned
  • UI/UX unset

Changed 4 years ago by vladmos

Changed 4 years ago by vladmos

comment:5 Changed 4 years ago by vladmos

  • Has patch set

There is already one optional keyword argument (takes_context=None), so it was reasonable to make a keyword argument name="new_name".

Tests and docs are included in the second patch.

comment:6 Changed 4 years ago by jezdez

  • Triage Stage changed from Accepted to Ready for checkin

comment:7 Changed 4 years ago by jezdez

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

In [16373]:

Fixed #12847 -- Added name parameter to simple_tag, assignment_tag and inclusion_tag helpers. Thanks, vladmos.

Note: See TracTickets for help on using tickets.
Back to Top