Code

Opened 8 years ago

Closed 8 years ago

Last modified 8 years ago

#2619 closed enhancement (wontfix)

Create a helper like simple_tag that sets the context

Reported by: slowness chen Owned by: mtredinnick
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:

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@… 8 years ago.

Download all attachments as: .zip

Change History (4)

Changed 8 years ago by slowness.chen@…

comment:1 Changed 8 years ago by anonymous

  • Summary changed from allow simple_tag to set context to [patch]allow simple_tag to set context

comment:2 Changed 8 years ago by mtredinnick

  • Summary changed from [patch]allow simple_tag to set context to Create 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 8 years ago by mtredinnick

  • Resolution set to wontfix
  • Status changed from new to 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.

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.