Opened 14 years ago

Closed 9 years ago

#12212 closed Bug (fixed)

inclusion_tag behavior on variable not in context is inconsistent

Reported by: Leo Shklovskii Owned by:
Component: Template system Version: dev
Severity: Normal Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: yes
Easy pickings: no UI/UX: no

Description

If you use a variable that doesn't exist in the context as an argument to a template tag created with @register.inclusion_tag() the tag throws a VariableDoesNotExist which is inconsistent with the way that all other tags behave in the template language.

I would expect that the wrapping inclusion_tag() code just passes None to the wrapped templatetag for the argument rather than blowing up.

Attachments (1)

12212.patch (5.6 KB ) - added by Leo Shklovskii 14 years ago.
Patch against r12699

Download all attachments as: .zip

Change History (10)

comment:1 by Russell Keith-Magee, 14 years ago

Triage Stage: UnreviewedAccepted

by Leo Shklovskii, 14 years ago

Attachment: 12212.patch added

Patch against r12699

comment:2 by Leo Shklovskii, 14 years ago

Has patch: set
milestone: 1.2
Owner: changed from nobody to Leo Shklovskii
Status: newassigned

There's two ways I could see of solving this: document the fact that they do this or fix the behavior. The former is relatively simple if the core committers decide its better so the attached patch does the latter.

Along the way I noticed that simple_tag has the same issue and fixed it as well. The patch includes doc changes and sets up tests for simple_tag and inclusion_tag.

Adding this for consideration into 1.2.

comment:3 by Russell Keith-Magee, 14 years ago

milestone: 1.21.3

Not critical for 1.2.

comment:4 by Matt McClanahan, 13 years ago

milestone: 1.3
Severity: Normal
Type: Bug

comment:5 by patchhammer, 13 years ago

Easy pickings: unset
Patch needs improvement: set

12212.patch fails to apply cleanly on to trunk

comment:6 by Leo Shklovskii, 13 years ago

Owner: Leo Shklovskii removed
Status: assignednew
UI/UX: unset

comment:7 by Leo Shklovskii, 13 years ago

milestone: 1.4

comment:8 by Jacob, 13 years ago

milestone: 1.4

Milestone 1.4 deleted

comment:9 by Tim Graham, 9 years ago

Resolution: fixed
Status: newclosed

I tested as far back as Django 1.4 and {% custom_tag nonexistent %} passes an empty string for nonexistent to the tag so it seems this has been fixed unless I misunderstood the issue.

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