Opened 16 years ago
Closed 13 years ago
#7438 closed New feature (duplicate)
Add keyword support to simple_tag and inclusion_tag
Reported by: | dougn | Owned by: | nobody |
---|---|---|---|
Component: | Template system | Version: | dev |
Severity: | Normal | Keywords: | keywords inclusion_tag simple_tag tags |
Cc: | Triage Stage: | Accepted | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | yes | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
for a project I found it very useful to support named keyword args on simple and inclusion tags.
Example:
@register.simple_tag def mytag(a, b=None, c=None): return {} @register.inclusion_tag("example.html") def inctag(data, **kwdargs): return kwdargs
{% mytag c="hello" a=3 %} {% inctag var1=3 user=user foo="bar" %} <!-- just a few of the errors detected as proper template errors --> {% mytag c=5 %} <!-- template error! "%s takes at least %s non-keyword arguments (%s given)" --> {% mytag 1 bad=4 %} <!-- template error! %s got an unexpected keyword argument '%s' --> {% mytag 1 c=3 c=4 %} <!-- template error! %s got multiple values for keyword argument '%s' -->
contains complete error
Including a patch for this, sans the unit tests. jezdez will help with that.
Attachments (1)
Change History (7)
by , 16 years ago
Attachment: | kwdarg_template_tag.patch added |
---|
comment:1 by , 16 years ago
FWIW, I had to wrap {% include %} tags with {% with %} tags sometimes, so I can see many use cases for the inclusion tag.
comment:2 by , 16 years ago
Has patch: | set |
---|---|
Needs tests: | set |
Triage Stage: | Unreviewed → Design decision needed |
comment:3 by , 14 years ago
Severity: | → Normal |
---|---|
Type: | → New feature |
comment:4 by , 13 years ago
Easy pickings: | unset |
---|---|
Triage Stage: | Design decision needed → Accepted |
UI/UX: | unset |
comment:5 by , 13 years ago
Since we've standardized on this "=" syntax is seems to make sense for the simple tags to support this, too.
comment:6 by , 13 years ago
Resolution: | → duplicate |
---|---|
Status: | new → closed |
Closing as dupe of #13956, which as a patch that's pretty much ready to go.
initial patch with full support (but no unit tests)