[Django] #25067: Allowing all characters when parsing inclusion templatetags

6 views
Skip to first unread message

Django

unread,
Jul 6, 2015, 5:36:16 AM7/6/15
to django-...@googlegroups.com
#25067: Allowing all characters when parsing inclusion templatetags
-------------------------+-------------------------------------------------
Reporter: srkunze | Owner: nobody
Type: Bug | Status: new
Component: | Version: master
Template system | Keywords: inclusion_tag, parse_bits,
Severity: Normal | token_kwargs
Triage Stage: | Has patch: 0
Unreviewed |
Easy pickings: 1 | UI/UX: 0
-------------------------+-------------------------------------------------
We use the inclusion_tag to create a special HTML DIV element with several
custom attributes; basically like this:

{{{
@inclusion_tag('...')
def my_tag(x, **kwargs):
return {
'y': x +1,
'extra_attrs': kwargs,
}
}}}

Unfortunately, django/template/base.py:token_kwargs does not recognize '-'
in variable names so that extra HTML attrs such as 'data-myattr' cannot be
added to the DIV.

Python as such supports special characters in **kwargs.

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

Django

unread,
Jul 6, 2015, 6:25:34 AM7/6/15
to django-...@googlegroups.com
#25067: Allowing all characters when parsing inclusion templatetags
-------------------------------------+-------------------------------------

Reporter: srkunze | Owner: nobody
Type: Bug | Status: new
Component: Template system | Version: master
Severity: Normal | Resolution:
Keywords: inclusion_tag, | Triage Stage:
parse_bits, token_kwargs | Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

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

* needs_docs: => 0
* needs_tests: => 0
* needs_better_patch: => 0


Old description:

> We use the inclusion_tag to create a special HTML DIV element with
> several custom attributes; basically like this:
>
> {{{
> @inclusion_tag('...')
> def my_tag(x, **kwargs):
> return {
> 'y': x +1,
> 'extra_attrs': kwargs,
> }
> }}}
>
> Unfortunately, django/template/base.py:token_kwargs does not recognize
> '-' in variable names so that extra HTML attrs such as 'data-myattr'
> cannot be added to the DIV.
>
> Python as such supports special characters in **kwargs.

New description:

We use the inclusion_tag to create a special HTML DIV element with several
custom attributes; basically like this:

{{{
@inclusion_tag('...')
def my_tag(x, **kwargs):
return {
'y': x +1,
'extra_attrs': kwargs,
}
}}}

Unfortunately, django/template/base.py:token_kwargs does not recognize '-'
in variable names so that extra HTML attrs such as 'data-myattr' cannot be
added to the DIV.

Python as such supports special characters in {{{**kwargs}}}.

--

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

Django

unread,
Jul 6, 2015, 9:01:47 AM7/6/15
to django-...@googlegroups.com
#25067: Allowing all characters when parsing inclusion templatetags
-------------------------------------+-------------------------------------
Reporter: srkunze | Owner: nobody
Type: Bug | Status: closed

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

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

* status: new => closed
* resolution: => duplicate


Comment:

Seems to be closely related to #21077 (I believe both reference the
`kwarg_re` regular expression) so I'm going to close this as a duplicate.
Feel free to put together a patch to assess feasibility and write to
mailing list if you disagree with the conclusions of that ticket.

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

Reply all
Reply to author
Forward
0 new messages