mirror of
https://github.com/django/django.git
synced 2025-07-24 05:36:15 +00:00
Fixed #23914 -- Improved {% now %} to allow storing its result in the context.
Thanks to Tim for the review.
This commit is contained in:
parent
3a9aa155e2
commit
c335c0fee9
4 changed files with 31 additions and 3 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue