Opened 8 years ago

Closed 6 years ago

Last modified 6 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: UI/UX:

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 7 years ago.

Download all attachments as: .zip

Change History (5)

comment:1 Changed 8 years ago by Malcolm Tredinnick

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.

Changed 7 years ago by Tim Graham

Attachment: 10545.diff added

comment:2 Changed 7 years ago by Tim Graham

Has patch: set

comment:3 Changed 6 years ago by Gabriel Hurley

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 Changed 6 years ago by Gabriel Hurley

(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