feat: dynamic slots, fills, and provides (#609)

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This commit is contained in:
Juro Oravec 2024-08-25 22:35:10 +02:00 committed by GitHub
parent 6793aec9b4
commit b90961b4a7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 521 additions and 140 deletions

View file

@ -188,6 +188,38 @@ class HtmlAttrsTests(BaseTestCase):
)
self.assertNotIn("override-me", rendered)
def test_tag_spread(self):
@register("test")
class AttrsComponent(Component):
template: types.django_html = """
{% load component_tags %}
<div {% html_attrs ...props class="another-class" %}>
content
</div>
""" # noqa: E501
def get_context_data(self, *args, attrs):
return {
"props": {
"attrs": attrs,
"defaults": {"class": "override-me"},
"class": "added_class",
"data-id": 123,
},
}
template = Template(self.template_str)
rendered = template.render(Context({"class_var": "padding-top-8"}))
self.assertHTMLEqual(
rendered,
"""
<div @click.stop="dispatch('click_event')" class="added_class another-class padding-top-8" data-id="123" x-data="{hello: 'world'}">
content
</div>
""", # noqa: E501
)
self.assertNotIn("override-me", rendered)
def test_tag_aggregate_args(self):
@register("test")
class AttrsComponent(Component):