[Django] #29457: Spaces between argument separator and argument in template filter generate error

5 views
Skip to first unread message

Django

unread,
May 30, 2018, 4:35:47 AM5/30/18
to django-...@googlegroups.com
#29457: Spaces between argument separator and argument in template filter generate
error
-------------------------------------------+------------------------
Reporter: oliver | Owner: nobody
Type: Bug | Status: new
Component: Template system | Version: master
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 1
UI/UX: 0 |
-------------------------------------------+------------------------
In the template filter system now, spaces between augment separator and
augments are not allowed.
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.

--
Ticket URL: <https://code.djangoproject.com/ticket/29457>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
May 30, 2018, 4:35:55 AM5/30/18
to django-...@googlegroups.com
#29457: Spaces between argument separator and argument in template filter generate
error
---------------------------------+--------------------------------------
Reporter: oliver | Owner: oliver
Type: Bug | Status: assigned

Component: Template system | Version: master
Severity: Normal | Resolution:

Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
---------------------------------+--------------------------------------
Changes (by oliver):

* status: new => assigned
* owner: nobody => oliver


--
Ticket URL: <https://code.djangoproject.com/ticket/29457#comment:1>

Django

unread,
May 30, 2018, 4:48:39 AM5/30/18
to django-...@googlegroups.com
#29457: Spaces between argument separator and argument in template filter generate
error
---------------------------------+--------------------------------------
Reporter: oliver | Owner: oliver
Type: Bug | Status: assigned
Component: Template system | Version: master
Severity: Normal | Resolution:

Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
---------------------------------+--------------------------------------

Comment (by oliver):

[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),
}
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/29457#comment:2>

Django

unread,
May 30, 2018, 5:11:30 AM5/30/18
to django-...@googlegroups.com
#29457: Spaces between argument separator and argument in template filter generate
error
---------------------------------+--------------------------------------
Reporter: oliver | Owner: oliver
Type: Bug | Status: closed

Component: Template system | Version: master
Severity: Normal | Resolution: wontfix
Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 1
Needs tests: 1 | Patch needs improvement: 0

Easy pickings: 1 | UI/UX: 0
---------------------------------+--------------------------------------
Changes (by Carlton Gibson):

* status: assigned => closed
* needs_docs: 0 => 1
* resolution: => wontfix
* needs_tests: 0 => 1


Comment:

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
[https://groups.google.com/forum/#!forum/django-developers 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.

--
Ticket URL: <https://code.djangoproject.com/ticket/29457#comment:3>

Django

unread,
May 31, 2018, 2:16:51 AM5/31/18
to django-...@googlegroups.com
#29457: Spaces between argument separator and argument in template filter generate
error
---------------------------------+--------------------------------------
Reporter: oliver | Owner: oliver
Type: Bug | Status: closed
Component: Template system | Version: master
Severity: Normal | Resolution: wontfix
Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 1
Needs tests: 1 | Patch needs improvement: 0

Easy pickings: 1 | UI/UX: 0
---------------------------------+--------------------------------------
Description changed by oliver:

Old description:

> In the template filter system now, spaces between augment separator and
> augments are not allowed.
> 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.

New description:

In the template filter system, spaces between augment separator and


augments are not allowed.
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.

--

--
Ticket URL: <https://code.djangoproject.com/ticket/29457#comment:4>

Django

unread,
May 31, 2018, 2:17:24 AM5/31/18
to django-...@googlegroups.com
#29457: Spaces between argument separator and argument in template filter generate
error
---------------------------------+--------------------------------------
Reporter: oliver | Owner: oliver
Type: Bug | Status: closed
Component: Template system | Version: master
Severity: Normal | Resolution: wontfix
Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 1
Needs tests: 1 | Patch needs improvement: 0

Easy pickings: 1 | UI/UX: 0
---------------------------------+--------------------------------------
Description changed by oliver:

Old description:

> In the template filter system, spaces between augment separator and


> augments are not allowed.
> 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.

New description:

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.

--

--
Ticket URL: <https://code.djangoproject.com/ticket/29457#comment:5>

Django

unread,
May 31, 2018, 2:20:24 AM5/31/18
to django-...@googlegroups.com
#29457: Spaces between argument separator and argument in template filter generate
error
---------------------------------+--------------------------------------
Reporter: oliver | Owner: oliver
Type: Bug | Status: closed
Component: Template system | Version: master
Severity: Normal | Resolution: wontfix
Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 1
Needs tests: 1 | Patch needs improvement: 0

Easy pickings: 1 | UI/UX: 0
---------------------------------+--------------------------------------

Comment (by oliver):

Replying to [comment:3 Carlton Gibson]:

Thanks for the review!
Are there any reasons that not allow spaces between separator and
argument?

> 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
[https://groups.google.com/forum/#!forum/django-developers 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.

--
Ticket URL: <https://code.djangoproject.com/ticket/29457#comment:6>

Django

unread,
May 31, 2018, 9:47:13 AM5/31/18
to django-...@googlegroups.com
#29457: Spaces between argument separator and argument in template filter generate
error
---------------------------------+--------------------------------------
Reporter: oliver | Owner: oliver
Type: Bug | Status: closed
Component: Template system | Version: master
Severity: Normal | Resolution: wontfix
Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 1
Needs tests: 1 | Patch needs improvement: 0

Easy pickings: 1 | UI/UX: 0
---------------------------------+--------------------------------------

Comment (by Tim Graham):

I agree with the wontfix decision. The arguments are described on the
[https://groups.google.com/d/topic/django-
developers/d4x7X91OLvQ/discussion django-developers thread].

--
Ticket URL: <https://code.djangoproject.com/ticket/29457#comment:7>

Reply all
Reply to author
Forward
0 new messages