Code

Opened 5 years ago

Closed 3 years ago

Last modified 3 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 timo 4 years ago.

Download all attachments as: .zip

Change History (5)

comment:1 Changed 5 years ago by mtredinnick

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to Accepted

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 4 years ago by timo

comment:2 Changed 4 years ago by timo

  • Has patch set

comment:3 Changed 3 years ago by gabrielhurley

  • Resolution set to fixed
  • Status changed from new to closed

(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 3 years ago by gabrielhurley

(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.

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.