Opened 7 years ago

Closed 7 years ago

#7462 closed (duplicate)

Add context support to simple_tag

Reported by: julien Owned by: julien
Component: Template system Version: master
Severity: Keywords:
Cc: django@… Triage Stage: Unreviewed
Has patch: yes Needs documentation: yes
Needs tests: yes Patch needs improvement: no
Easy pickings: UI/UX:

Description

This patch is backward compatible and add context support to simple_tag, in the same way as inclusion_tag already does.

Attachments (1)

simple_tag_takes_context.diff (7.2 KB) - added by julien 7 years ago.

Download all attachments as: .zip

Change History (7)

comment:1 Changed 7 years ago by julien

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

Just adding that:

You can still do:

@register.simple_tag
def my_tag(bla):

You can now also do:

@register.simple_tag(takes_context=True)
def my_tag(context, bla):

Note that the following (with brackets but without arguments) will be accepted and work the same as the current code (without brackets):

@register.simple_tag()
def my_tag(bla):

comment:2 Changed 7 years ago by simon

  • Needs documentation set
  • Needs tests set

Changed 7 years ago by julien

comment:3 Changed 7 years ago by julien

Updated patch with regression tests and doc.

comment:4 Changed 7 years ago by emulbreh

duplicate of #1105, which also adds takes_block=True but only has an outdated patch.

comment:5 Changed 7 years ago by julien

  • Owner changed from nobody to julien

Ok, I'm now working on adding takes_block support as well.

comment:6 Changed 7 years ago by julien

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

I'll close this one in favour of ticket #1105. I've posted the follow up of my work there so check it out for more updates.

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