Opened 12 years ago

Closed 12 years ago

#764 closed defect (fixed)

[i18n] blocktrans parsing error when filter argument contains spaces

Reported by: Nebojša Đorđević - nesh <nesh@…> 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: UI/UX:


When I using this:

{% blocktrans with object.pub_date|date:"F j, Y" as date %}
Posted by <strong>{{ }}</strong> on {{ date }}
{% endblocktrans %}

I'm getting following exception

  File "/store/django/django/core/template/", line 221, in parse
    nodelist.append(registered_tags[command](self, token))

  File "/store/django/django/templatetags/", line 189, in do_block_translate
    (countervar, counter, extra_context) = BlockTranslateParser(token.contents).top()

  File "/store/django/django/templatetags/", 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 Changed 12 years ago by Nebojša Đorđević - nesh <nesh@…>

Component: Admin interfaceTemplate system

comment:2 Changed 12 years ago by hugo

Owner: changed from Adrian Holovaty to hugo

comment:3 Changed 12 years ago by hugo

Status: newassigned

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.

comment:4 Changed 12 years ago by hugo

Resolution: fixed
Status: assignedclosed

(In [1207]) fixes #764 - the TokenParser now respects string parameters to filters that contain blanks.

Note: See TracTickets for help on using tickets.
Back to Top