Opened 10 years ago

Closed 10 years ago

Last modified 10 years ago

#2619 closed enhancement (wontfix)

Create a helper like simple_tag that sets the context

Reported by: slowness chen Owned by: Malcolm Tredinnick
Component: Template system Version:
Severity: normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:


If there are many places in which you need to use inclusion_tag , it gets annoying that you have to extract all these *short and simple* snippets into separate template files.
If simple_tag can also set context, that will be more convenient. for detail see

Attachments (1)

simple_tag_set_context_r3680.diff (712 bytes) - added by slowness.chen@… 10 years ago.

Download all attachments as: .zip

Change History (4)

Changed 10 years ago by slowness.chen@…

comment:1 Changed 10 years ago by anonymous

Summary: allow simple_tag to set context[patch]allow simple_tag to set context

comment:2 Changed 10 years ago by Malcolm Tredinnick

Summary: [patch]allow simple_tag to set contextCreate a helper like simple_tag that sets the context

I agree with the idea behind this ticket (having an easy way to set the context), but I don't like the implementation. Having the decorator behave differently depending upon whether the return value is a string or a dictionary is not very Pythonic.

We should create a separate decorator for setting the context. If we can do this without duplicating all the code behind simple_tag(), that would be ideal.

So I'm not going to apply this patch (and removing the keyword, since the patch is not valid), but I'm leaving the ticket open, since it's a useful idea. There are slightly higher priorities at the moment, but we should eventually implement this.

comment:3 Changed 10 years ago by Malcolm Tredinnick

Resolution: wontfix
Status: newclosed

I'm going to close this in favour of #1105. Once we can pass the context into a tag function like this, the programmer can set it and return and empty string if they want to.

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