Opened 15 years ago

Closed 14 years ago

Last modified 14 years ago

#10545 closed (fixed)

Developing custom tag - setting context is missing a limitation

Reported by: yaniv.haber@… Owned by: nobody
Component: Documentation Version: 1.0
Severity: Keywords: custom template tags
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

In the documentation of SETTING A VARIABLE IN THE CONTEXT (http://docs.djangoproject.com/en/dev/howto/custom-template-tags/#setting-a-variable-in-the-context) it is not mentioned that any variable set to the context will only be available in the same BLOCK part of the template in which it was assigned.
This limitation needs to be mentioned in the docs and hopefully solved in a future version.

Attachments (1)

10545.diff (835 bytes ) - added by Tim Graham 14 years ago.

Download all attachments as: .zip

Change History (5)

comment:1 by Malcolm Tredinnick, 15 years ago

Triage Stage: UnreviewedAccepted

It should certainly be mentioned, you're right about. However the behaviour is intentional. It provides a scope for the variables so that they don't clash with other things. Yes, I realise there are cases where people sometimes want a more extensive visibility scope, so no need to post that you have such a case. We have scoping, though, and it's relied upon in a lot of places, so I wouldn't expect it to change.

by Tim Graham, 14 years ago

Attachment: 10545.diff added

comment:2 by Tim Graham, 14 years ago

Has patch: set

comment:3 by Gabriel Hurley, 14 years ago

Resolution: fixed
Status: newclosed

(In [14350]) Fixed #10545 -- Mentioned that template context variables are scoped to the block in which they're assigned. Thanks to yaniv.haber for the report and timo for the patch.

comment:4 by Gabriel Hurley, 14 years ago

(In [14351]) [1.2.X] Fixed #10545 -- Mentioned that template context variables only exist in the scope of th block in which they're assigned. Thanks to yaniv.haber for the report and timo for the patch.

Backport of [14350] from trunk.

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