Opened 20 years ago
Closed 20 years ago
#764 closed defect (fixed)
[i18n] blocktrans parsing error when filter argument contains spaces
| Reported by: | Owned by: | hugo | |
|---|---|---|---|
| Component: | Template system | Version: | |
| Severity: | normal | Keywords: | |
| Cc: | nesh@… | Triage Stage: | Unreviewed |
| Has patch: | no | Needs documentation: | no |
| Needs tests: | no | Patch needs improvement: | no |
| Easy pickings: | no | UI/UX: | no |
Description
When I using this:
{% blocktrans with object.pub_date|date:"F j, Y" as date %}
Posted by <strong>{{ object.author }}</strong> on {{ date }}
{% endblocktrans %}
I'm getting following exception
...
File "/store/django/django/core/template/__init__.py", line 221, in parse
nodelist.append(registered_tags[command](self, token))
File "/store/django/django/templatetags/i18n.py", line 189, in do_block_translate
(countervar, counter, extra_context) = BlockTranslateParser(token.contents).top()
File "/store/django/django/templatetags/i18n.py", line 178, in top
raise TemplateSyntaxError, "variable bindings in 'blocktrans' must be 'with value as variable'"
TemplateSyntaxError: variable bindings in 'blocktrans' must be 'with value as variable'
Change History (4)
comment:1 by , 20 years ago
| Component: | Admin interface → Template system |
|---|
comment:2 by , 20 years ago
| Owner: | changed from to |
|---|
comment:3 by , 20 years ago
| Status: | new → assigned |
|---|
comment:4 by , 20 years ago
| Resolution: | → fixed |
|---|---|
| Status: | assigned → closed |
Note:
See TracTickets
for help on using tickets.
This is a problem of the still-not-perfect parser for parameters in the blocktrans tag. It doesn't currently handle any filter expressions that contain blanks. Actually that's a common problem, if you use the split-on-whitespace approach to "preparse" the tag arguments, you end up with this problem, as it breaks on blanks in filter expressions. I think this can be fixed by making the tag parser a bit more intelligent to correctly handle filter expressions with parameters. Will have a look at that at the weekend.