mirror of
https://github.com/django-components/django-components.git
synced 2025-10-21 11:11:43 +00:00
fix: do not aggregate kwargs that start with colon (#561)
This commit is contained in:
parent
8cb88558f0
commit
fbbbf6c694
2 changed files with 32 additions and 1 deletions
|
@ -3,6 +3,7 @@ from django.template.base import Parser
|
|||
|
||||
from django_components import component, types
|
||||
from django_components.component import safe_resolve_dict, safe_resolve_list
|
||||
from django_components.template_parser import process_aggregate_kwargs
|
||||
from django_components.templatetags.component_tags import _parse_component_with_args
|
||||
|
||||
from .django_test_setup import setup_test_config
|
||||
|
@ -88,3 +89,31 @@ class ParserComponentTest(BaseTestCase):
|
|||
abc
|
||||
""",
|
||||
)
|
||||
|
||||
|
||||
class AggregateKwargsTest(BaseTestCase):
|
||||
def test_aggregate_kwargs(self):
|
||||
processed = process_aggregate_kwargs(
|
||||
{
|
||||
"attrs:@click.stop": "dispatch('click_event')",
|
||||
"attrs:x-data": "{hello: 'world'}",
|
||||
"attrs:class": "class_var",
|
||||
"my_dict:one": 2,
|
||||
"three": "four",
|
||||
":placeholder": "No text",
|
||||
}
|
||||
)
|
||||
|
||||
self.assertDictEqual(
|
||||
processed,
|
||||
{
|
||||
"attrs": {
|
||||
"@click.stop": "dispatch('click_event')",
|
||||
"x-data": "{hello: 'world'}",
|
||||
"class": "class_var",
|
||||
},
|
||||
"my_dict": {"one": 2},
|
||||
"three": "four",
|
||||
":placeholder": "No text",
|
||||
},
|
||||
)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue