{{{
@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.
* 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>
* 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>