Opened 6 years ago

Closed 6 years ago

Last modified 6 years ago

#29457 closed Bug (wontfix)

Spaces between argument separator and argument in template filter generate error — at Version 5

Reported by: oliver Owned by: oliver
Component: Template system Version: dev
Severity: Normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: yes
Needs tests: yes Patch needs improvement: no
Easy pickings: yes UI/UX: no

Description (last modified by oliver)

In the template filter system, spaces between augment separator and augments generate error.
For example, the following template code generates the following error.

{{ value | filter: "arg"}}
TemplateSyntaxError at /
Could not parse the remainder: ': "arg"' from 'value | filter: "arg"'

It would be better to allow spaces between them.

Change History (5)

comment:1 by oliver, 6 years ago

Owner: changed from nobody to oliver
Status: newassigned

comment:2 by oliver, 6 years ago

https://github.com/django/django/pull/10009

I added "\s*" next to "(arg_sep)"

filter_raw_string = r"""
^(?P<constant>%(constant)s)|
^(?P<var>[%(var_chars)s]+|%(num)s)|
 (?:\s*%(filter_sep)s\s*
     (?P<filter_name>\w+)
         (?:%(arg_sep)s\s*
             (?:
              (?P<constant_arg>%(constant)s)|
              (?P<var_arg>[%(var_chars)s]+|%(num)s)
             )
         )?
 )""" % {
    'constant': constant_string,
    'num': r'[-+\.]?\d[\d\.e]*',
    'var_chars': r'\w\.',
    'filter_sep': re.escape(FILTER_SEPARATOR),
    'arg_sep': re.escape(FILTER_ARGUMENT_SEPARATOR),
}

comment:3 by Carlton Gibson, 6 years ago

Needs documentation: set
Needs tests: set
Resolution: wontfix
Status: assignedclosed

Hi Oliver. Thanks for the input here.

I don't think we can just introduce a syntax change to the DTL without some discussion around that.
I'm not sure a consensus would form in favour of the change, but we need to check.

As such I'm going to close this as wontfix.

If you want to push this forwards please post to the Django Developers mailing list explaining your proposed change and the reasons for it. (Please link here and to the PR on GitHub.)

If there's a consensus around the change then we can re-open this ticket and the PR.

If we were to make this change, it would need tests, and the new syntax would need to be documented too.

Thanks again.

comment:4 by oliver, 6 years ago

Description: modified (diff)

comment:5 by oliver, 6 years ago

Description: modified (diff)
Note: See TracTickets for help on using tickets.
Back to Top