#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)
Change History (4)
by , 19 years ago
| Attachment: | simple_tag_set_context_r3680.diff added |
|---|
comment:1 by , 19 years ago
| Summary: | allow simple_tag to set context → [patch]allow simple_tag to set context |
|---|
comment:2 by , 19 years ago
| Summary: | [patch]allow simple_tag to set context → Create a helper like simple_tag that sets the context |
|---|
comment:3 by , 19 years ago
| Resolution: | → wontfix |
|---|---|
| Status: | new → closed |
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.
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.