Opened 10 years ago
Closed 10 years ago
#23914 closed New feature (fixed)
Allow the {% now %} tag to store its output in the context
Reported by: | Baptiste Mispelon | Owned by: | Baptiste Mispelon |
---|---|---|---|
Component: | Template system | Version: | dev |
Severity: | Normal | Keywords: | |
Cc: | Triage Stage: | Ready for checkin | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
I hit this issue when trying to use the value of the current year inside a translated string.
Normally, you'd do something like this:
{% blocktrans %}Current year: {% now 'Y' %}{% endblocktrans %}
But this doesn't work because blocktrans
doesn't allow other tags inside.
So I propose adding the as varname
syntax to {% now %}
so you can do something like this:
{% now 'Y' as current_year %} {% blocktrans %}Current year: {{ current_year }}{% endblocktrans %}
Change History (3)
comment:1 by , 10 years ago
Has patch: | set |
---|
comment:2 by , 10 years ago
Triage Stage: | Unreviewed → Ready for checkin |
---|---|
Version: | 1.6 → master |
comment:3 by , 10 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
Note:
See TracTickets
for help on using tickets.
PR here: https://github.com/django/django/pull/3621