diff options
| author | Baptiste Mispelon <bmispelon@gmail.com> | 2014-11-25 19:24:57 +0100 |
|---|---|---|
| committer | Baptiste Mispelon <bmispelon@gmail.com> | 2014-11-25 22:11:35 +0100 |
| commit | c335c0fee92a658b6a09453ae73e5c542f10703a (patch) | |
| tree | 713339592a5168d3205c470fb27cff443585425e /docs | |
| parent | 3a9aa155e2f7326df669953980ac87e78e932c43 (diff) | |
Fixed #23914 -- Improved {% now %} to allow storing its result in the context.
Thanks to Tim for the review.
Diffstat (limited to 'docs')
| -rw-r--r-- | docs/ref/templates/builtins.txt | 12 | ||||
| -rw-r--r-- | docs/releases/1.8.txt | 3 |
2 files changed, 15 insertions, 0 deletions
diff --git a/docs/ref/templates/builtins.txt b/docs/ref/templates/builtins.txt index 2b3d48d90e..146f2eacd6 100644 --- a/docs/ref/templates/builtins.txt +++ b/docs/ref/templates/builtins.txt @@ -799,6 +799,18 @@ This would display as "It is the 4th of September". It is {% now "SHORT_DATETIME_FORMAT" %} + +You can also use the syntax ``{% now "Y" as current_year %}`` to store the +output inside a variable. This is useful if you want to use ``{% now %}`` +inside a template tag like :ttag:`blocktrans` for example:: + + {% now "Y" as current_year %} + {% blocktrans %}Copyright {{ current_year }}{% endblocktrans %} + +.. versionadded:: 1.8 + +The ability to use the "as" syntax was added. + .. templatetag:: regroup regroup diff --git a/docs/releases/1.8.txt b/docs/releases/1.8.txt index 73ad244cfb..b342234ef9 100644 --- a/docs/releases/1.8.txt +++ b/docs/releases/1.8.txt @@ -419,6 +419,9 @@ Templates * Added a :class:`locmem.Loader <django.template.loaders.locmem.Loader>` class that loads Django templates from a Python dictionary. +* The :ttag:`now` tag can now store its output in a context variable with the + usual syntax: ``{% now 'j n Y' as varname %}``. + Requests and Responses ^^^^^^^^^^^^^^^^^^^^^^ |
