Opened 18 years ago

Closed 18 years ago

Last modified 18 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: no UI/UX: no

Description

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 http://groups.google.com/group/django-developers/browse_frm/thread/3c4f8112341038d7/b791042941e34904?hl=zh-CN#b791042941e34904

Attachments (1)

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

Download all attachments as: .zip

Change History (4)

by slowness.chen@…, 18 years ago

comment:1 by anonymous, 18 years ago

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

comment:2 by Malcolm Tredinnick, 18 years ago

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 by Malcolm Tredinnick, 18 years ago

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