Spaces between argument separator and argument in template filter generate error

classic Classic list List threaded Threaded
15 messages Options
Reply | Threaded
Open this post in threaded view
|

Spaces between argument separator and argument in template filter generate error

oliver-2
In the template filter system now,
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"'
https://code.djangoproject.com/ticket/29457

What do you think of this ticket?

--
You received this message because you are subscribed to the Google Groups "Django developers (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/django-developers.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/41376429-949c-4202-9074-5dc0200fc8ef%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Spaces between argument separator and argument in template filter generate error

oliver-2
Are there any reasons that not allow spaces between separator and arg?

2018년 5월 31일 목요일 오전 11시 41분 22초 UTC+9, [hidden email] 님의 말:
In the template filter system now,
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"'
<a href="https://code.djangoproject.com/ticket/29457" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fcode.djangoproject.com%2Fticket%2F29457\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFowrSgDhSDH9nVWYT3VJQroRA-mw&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fcode.djangoproject.com%2Fticket%2F29457\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFowrSgDhSDH9nVWYT3VJQroRA-mw&#39;;return true;">https://code.djangoproject.com/ticket/29457

What do you think of this ticket?

--
You received this message because you are subscribed to the Google Groups "Django developers (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/django-developers.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/131b5095-c5b7-4492-92fa-e58912ac842a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Spaces between argument separator and argument in template filter generate error

Adam Johnson-2
In reply to this post by oliver-2
I think it's better to be conservative here and leave it as-is, the current syntax has worked for years and this change doesn't really reduce the risk of bugs.

On Thu, 31 May 2018 at 03:34, <[hidden email]> wrote:
In the template filter system now,
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"'
https://code.djangoproject.com/ticket/29457

What do you think of this ticket?

--
You received this message because you are subscribed to the Google Groups "Django developers (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/django-developers.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/41376429-949c-4202-9074-5dc0200fc8ef%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


--
Adam

--
You received this message because you are subscribed to the Google Groups "Django developers (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/django-developers.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/CAMyDDM2GpwgemVHKkrr8yM%2B9%2B35Wk8N7P0_2oTekL_kSwaKkdQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Spaces between argument separator and argument in template filter generate error

James Bennett
In reply to this post by oliver-2
On Thu, May 31, 2018 at 1:39 AM, <[hidden email]> wrote:
Are there any reasons that not allow spaces between separator and arg?

Every optional variant of template syntax is a potential source of bugs or compatibility issues for the future. And a potential source of confusion when someone is trying to learn by reading code -- why did one developer do it *this* way, while another developer did it *that* way? And another choice every dev team has to make when putting together their style guide, and another option they have to set on their linters, to make sure they get a consistent codebase.

For these reasons, the default position should be "don't add it unless there's a very good reason to". If there is a good reason to add it, please explain so we can understand why you're requesting it.

--
You received this message because you are subscribed to the Google Groups "Django developers (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/django-developers.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/CAL13Cg98d4UX2RcypOeiRnCU-TczNzqO90unjLgt4y8q8YugPg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Spaces between argument separator and argument in template filter generate error

oliver-2
In reply to this post by oliver-2
Thank you for your reply.
I understand your opinion well

2018년 5월 31일 목요일 오전 11시 41분 22초 UTC+9, [hidden email] 님의 말:
In the template filter system now,
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"'
<a href="https://code.djangoproject.com/ticket/29457" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fcode.djangoproject.com%2Fticket%2F29457\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFowrSgDhSDH9nVWYT3VJQroRA-mw&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fcode.djangoproject.com%2Fticket%2F29457\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFowrSgDhSDH9nVWYT3VJQroRA-mw&#39;;return true;">https://code.djangoproject.com/ticket/29457

What do you think of this ticket?

--
You received this message because you are subscribed to the Google Groups "Django developers (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/django-developers.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/b133457b-e474-47b6-b37f-cdab3fa6ee2f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Spaces between argument separator and argument in template filter generate error

Collin Anderson-2
Maybe it would be worth having a more friendly error message?

On Thu, May 31, 2018 at 8:59 PM, <[hidden email]> wrote:
Thank you for your reply.
I understand your opinion well

2018년 5월 31일 목요일 오전 11시 41분 22초 UTC+9, [hidden email] 님의 말:
In the template filter system now,
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"'
https://code.djangoproject.com/ticket/29457

What do you think of this ticket?

--
You received this message because you are subscribed to the Google Groups "Django developers (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/django-developers.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/b133457b-e474-47b6-b37f-cdab3fa6ee2f%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Django developers (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/django-developers.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/CAFO84S4oFP_hxC6u84HagpXJy3ko7hvTkQjTO85CNfegFSX%3DUg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Spaces between argument separator and argument in template filter generate error

Alasdair Nicol
On Friday, 1 June 2018 03:06:01 UTC+1, Collin Anderson wrote:
Maybe it would be worth having a more friendly error message?


I agree, it would be good to improve the message.

I've also seen users confused by the "could not parse the remainder" message when they forget the spaces around boolean operators, for example:

    {% if foo=='bar' %}

On Thu, May 31, 2018 at 8:59 PM, <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="i5DW6qUuAwAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">oli...@...> wrote:
Thank you for your reply.
I understand your opinion well

2018년 5월 31일 목요일 오전 11시 41분 22초 UTC+9, [hidden email] 님의 말:
In the template filter system now,
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"'
<a href="https://code.djangoproject.com/ticket/29457" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fcode.djangoproject.com%2Fticket%2F29457\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFowrSgDhSDH9nVWYT3VJQroRA-mw&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fcode.djangoproject.com%2Fticket%2F29457\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFowrSgDhSDH9nVWYT3VJQroRA-mw&#39;;return true;">https://code.djangoproject.com/ticket/29457

What do you think of this ticket?

--
You received this message because you are subscribed to the Google Groups "Django developers (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email to <a href="javascript:" target="_blank" gdf-obfuscated-mailto="i5DW6qUuAwAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">django-develop...@googlegroups.com.
To post to this group, send email to <a href="javascript:" target="_blank" gdf-obfuscated-mailto="i5DW6qUuAwAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">django-d...@googlegroups.com.
Visit this group at <a href="https://groups.google.com/group/django-developers" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/group/django-developers&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/group/django-developers&#39;;return true;">https://groups.google.com/group/django-developers.
To view this discussion on the web visit <a href="https://groups.google.com/d/msgid/django-developers/b133457b-e474-47b6-b37f-cdab3fa6ee2f%40googlegroups.com?utm_medium=email&amp;utm_source=footer" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/d/msgid/django-developers/b133457b-e474-47b6-b37f-cdab3fa6ee2f%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/msgid/django-developers/b133457b-e474-47b6-b37f-cdab3fa6ee2f%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;">https://groups.google.com/d/msgid/django-developers/b133457b-e474-47b6-b37f-cdab3fa6ee2f%40googlegroups.com.

For more options, visit <a href="https://groups.google.com/d/optout" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;">https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Django developers (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/django-developers.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/4747632d-4b1e-43f5-a99f-11b2efbaa49f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Spaces between argument separator and argument in template filter generate error

Curtis Maloney-2
In reply to this post by oliver-2
On 05/31/2018 06:39 PM, [hidden email] wrote:
> Are there any reasons that not allow spaces between separator and arg?

My first thought would be that it starts making the syntax looser,
meaning more things that are currently error cases would be accepted as
valid.

Which means mistakes will no longer raise errors.

--
Curtis


> 2018년 5월 31일 목요일 오전 11시 41분 22초 UTC+9, [hidden email]
> 의 말:
>
>     In the template filter system now,
>
>     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"'
>
>     https://code.djangoproject.com/ticket/29457
>     <https://code.djangoproject.com/ticket/29457>
>
>
>     What do you think of this ticket?
>
> --
> You received this message because you are subscribed to the Google
> Groups "Django developers (Contributions to Django itself)" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to [hidden email]
> <mailto:[hidden email]>.
> To post to this group, send email to [hidden email]
> <mailto:[hidden email]>.
> Visit this group at https://groups.google.com/group/django-developers.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-developers/131b5095-c5b7-4492-92fa-e58912ac842a%40googlegroups.com 
> <https://groups.google.com/d/msgid/django-developers/131b5095-c5b7-4492-92fa-e58912ac842a%40googlegroups.com?utm_medium=email&utm_source=footer>.
> For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Django developers  (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/django-developers.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/ab2d6097-51e4-56a2-e096-3a8189cdc6eb%40tinbrain.net.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Spaces between argument separator and argument in template filter generate error

oliver-2
In reply to this post by oliver-2
Currently, django template system allow spaces between filter separator and filter name, also value name and filter separator. 
So, following is ok.

    {{ value    |    filter:"arg" }}
    {{ value|filter:"arg" }}

But, following can't be parsed

    {{ value|filter: "arg" }}

I think that this syntax is inconsistent.
So allowing spaces between filter name and filter separator is better.


--
You received this message because you are subscribed to the Google Groups "Django developers (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/django-developers.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/8d9bc320-222b-42cf-934e-644d29cb6ba0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Spaces between argument separator and argument in template filter generate error

oliver-2


2018년 6월 5일 화요일 오전 10시 52분 16초 UTC+9, [hidden email] 님의 말:
Currently, django template system allow spaces between filter separator and filter name, also value name and filter separator. 
So, following is ok.

    {{ value    |    filter:"arg" }}
    {{ value|filter:"arg" }}

But, following can't be parsed

    {{ value|filter: "arg" }}

I think that this syntax is inconsistent.
So allowing spaces between filter argument separator and filter argument is better.


--
You received this message because you are subscribed to the Google Groups "Django developers (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/django-developers.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/dada5fc6-3fad-4811-af17-4c911d4ab2a4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Spaces between argument separator and argument in template filter generate error

oliver-2
In reply to this post by oliver-2
Currently, spaces between filter separator( | ) and filter name is allowed. Also, value name and filter separator.
So, following is allowed.

    {{ value    |    filter:"arg" }}
    {{ value|filter:"arg" }}

But, following is not allowed.

    {{ value|filter: "arg" }}

users are confused by the inconsistency. 

I think that either the error message or syntax should be improved.

--
You received this message because you are subscribed to the Google Groups "Django developers (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/django-developers.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/7152e2da-bd50-4496-b173-18466e2da01d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Spaces between argument separator and argument in template filter generate error

oliver-2
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
(?:
(?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),
}

allowing spaces can be done by adding \s* after (arg_sep)s

2018년 6월 5일 화요일 오전 11시 17분 51초 UTC+9, [hidden email] 님의 말:
Currently, spaces between filter separator( | ) and filter name is allowed. Also, value name and filter separator.
So, following is allowed.

    {{ value    |    filter:"arg" }}
    {{ value|filter:"arg" }}

But, following is not allowed.

    {{ value|filter: "arg" }}

users are confused by the inconsistency. 

I think that either the error message or syntax should be improved.

--
You received this message because you are subscribed to the Google Groups "Django developers (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/django-developers.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/2f27f356-e225-441a-8fd2-4f49d23f5d14%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Spaces between argument separator and argument in template filter generate error

oliver-2
In reply to this post by oliver-2
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
(?:
(?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),
}

allowing spaces can be done by simply adding \s* after (arg_sep)s

--
You received this message because you are subscribed to the Google Groups "Django developers (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/django-developers.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/f87d71f0-c3d6-4155-bff3-b7693123c60c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Spaces between argument separator and argument in template filter generate error

Florian Apolloner


On Tuesday, June 5, 2018 at 4:30:03 AM UTC+2, [hidden email] wrote:
allowing spaces can be done by simply adding \s* after (arg_sep)s

\s is __not__ the regex for spaces

--
You received this message because you are subscribed to the Google Groups "Django developers (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/django-developers.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/3b212784-43ab-409c-88ad-59c14a2c5cf8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Spaces between argument separator and argument in template filter generate error

oliver-2
Sorry my mistake. It means white spaces  character not spaces

2018년 6월 6일 수요일 오후 6시 3분 48초 UTC+9, Florian Apolloner 님의 말:


On Tuesday, June 5, 2018 at 4:30:03 AM UTC+2, [hidden email] wrote:
allowing spaces can be done by simply adding \s* after (arg_sep)s

\s is __not__ the regex for spaces

--
You received this message because you are subscribed to the Google Groups "Django developers (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/django-developers.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/03eff6d7-7aa5-441f-a2d1-16d2f2db07b4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.