Opened 18 years ago

Closed 18 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: 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 Nebojša Đorđević - nesh <nesh@…>, 18 years ago

Component: Admin interfaceTemplate system

comment:2 by hugo, 18 years ago

Owner: changed from Adrian Holovaty to hugo

comment:3 by hugo, 18 years ago

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 by hugo, 18 years ago

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