Opened 15 years ago
Closed 12 years ago
#12332 closed Bug (duplicate)
{% blocktrans with value as variable %} syntax cannot parse literal values passed through filters
Reported by: | Alun Bestor | Owned by: | nobody |
---|---|---|---|
Component: | Template system | Version: | dev |
Severity: | Normal | Keywords: | blocktrans i18n |
Cc: | Triage Stage: | Accepted | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
As a contrived example:
{% blocktrans with "String Literal"|lower as lowercase_string %}Here is a lowercase string: {{ lowercase_string }}{% endblocktrans %}
This example will fail in Django 1.1 and 1.2 trunk with:
TemplateSyntaxError: variable bindings in 'blocktrans' must be 'with value as variable'
The example will be parsed successfully if the filter is omitted, or if the filtered value is a context variable instead of a literal (e.g. string_var|lower).
One workaround for the parsing problem would be to use the following code:
{% with "String Literal"|lower as lowercase_string %} {% blocktrans with lowercase_string as lowercase_string %}Here is a lowercase string: {{ lowercase_string }}{% endblocktrans %} {‰ endwith %}
(In the contrived example it is of course unnecessary to use the lower filter on a literal value; the actual case came up with a custom filter which processes a value differently depending on active settings.)
Change History (5)
comment:1 by , 15 years ago
Triage Stage: | Unreviewed → Accepted |
---|
comment:2 by , 14 years ago
Severity: | → Normal |
---|---|
Type: | → Bug |
comment:3 by , 13 years ago
UI/UX: | unset |
---|
comment:5 by , 12 years ago
Resolution: | → duplicate |
---|---|
Status: | new → closed |
Duplicate of #5971, fixed in b459f5b7e3be65bbd554e03626ff255d4a68e9fc.
Change UI/UX from NULL to False.