diff options
| author | Tommy Beadle <tbeadle@arbor.net> | 2015-04-13 10:57:44 -0400 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2015-04-14 08:01:16 -0400 |
| commit | 6bfd864ff2a7d4903d485ee40094a1315da8221b (patch) | |
| tree | 26c51d352c9e8aa8b2b919c226a61401260f87f6 /docs/ref | |
| parent | c612786cf15e2e1d00162ed4e335e83b75e6c978 (diff) | |
Fixed #24603 -- Allowed Context.update() to be used as a context manager.
Diffstat (limited to 'docs/ref')
| -rw-r--r-- | docs/ref/templates/api.txt | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/docs/ref/templates/api.txt b/docs/ref/templates/api.txt index 077330f6ce..5e56eff1d4 100644 --- a/docs/ref/templates/api.txt +++ b/docs/ref/templates/api.txt @@ -497,6 +497,21 @@ the stack instead of an empty one. >>> c['foo'] 'first level' +Like ``push()``, you can use ``update()`` as a context manager to ensure a +matching ``pop()`` is called. + + >>> c = Context() + >>> c['foo'] = 'first level' + >>> with c.update({'foo': 'second level'}): + ... c['foo'] + 'second level' + >>> c['foo'] + 'first level' + +.. versionadded:: 1.9 + + The ability to use ``update()`` as a context manager was added. + Using a ``Context`` as a stack comes in handy in :ref:`some custom template tags <howto-writing-custom-template-tags>`. |
