mirror of
https://github.com/django-components/django-components.git
synced 2025-10-17 09:17:10 +00:00
refactor: Backbone for passing JS and CSS variables (#861)
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This commit is contained in:
parent
296da4a1e8
commit
fe67d90547
28 changed files with 1181 additions and 594 deletions
|
@ -150,7 +150,7 @@ class DynamicExprTests(BaseTestCase):
|
|||
|
||||
self.assertEqual(
|
||||
rendered.strip(),
|
||||
"<!-- _RENDERED SimpleComponent_5b8d97,a1bc3e -->\n <div>lorem</div>\n <div>True</div>\n <div>[{'a': 1}, {'a': 2}]</div>", # noqa: E501
|
||||
"<!-- _RENDERED SimpleComponent_5b8d97,a1bc3f,, -->\n<div data-djc-id-a1bc3f>lorem</div>\n<div data-djc-id-a1bc3f>True</div>\n<div data-djc-id-a1bc3f>[{'a': 1}, {'a': 2}]</div>", # noqa: E501
|
||||
)
|
||||
|
||||
@parametrize_context_behavior(["django", "isolated"])
|
||||
|
@ -220,7 +220,13 @@ class DynamicExprTests(BaseTestCase):
|
|||
|
||||
self.assertEqual(
|
||||
rendered.strip(),
|
||||
"<!-- _RENDERED SimpleComponent_743413,a1bc3e -->\n <div>lorem ipsum dolor</div>\n <div>True</div>\n <div>[{'a': 1}, {'a': 2}]</div>\n <div>{'a': 3}</div>", # noqa E501
|
||||
(
|
||||
"<!-- _RENDERED SimpleComponent_743413,a1bc3f,, -->\n"
|
||||
"<div data-djc-id-a1bc3f>lorem ipsum dolor</div>\n"
|
||||
"<div data-djc-id-a1bc3f>True</div>\n"
|
||||
"<div data-djc-id-a1bc3f>[{'a': 1}, {'a': 2}]</div>\n"
|
||||
"<div data-djc-id-a1bc3f>{'a': 3}</div>"
|
||||
),
|
||||
)
|
||||
|
||||
@parametrize_context_behavior(["django", "isolated"])
|
||||
|
@ -290,7 +296,13 @@ class DynamicExprTests(BaseTestCase):
|
|||
|
||||
self.assertEqual(
|
||||
rendered.strip(),
|
||||
"<!-- _RENDERED SimpleComponent_e258c0,a1bc3e -->\n <div></div>\n <div> abc</div>\n <div></div>\n <div> </div>", # noqa E501
|
||||
(
|
||||
"<!-- _RENDERED SimpleComponent_e258c0,a1bc3f,, -->\n"
|
||||
"<div data-djc-id-a1bc3f></div>\n"
|
||||
"<div data-djc-id-a1bc3f> abc</div>\n"
|
||||
"<div data-djc-id-a1bc3f></div>\n"
|
||||
"<div data-djc-id-a1bc3f> </div>"
|
||||
),
|
||||
)
|
||||
|
||||
@parametrize_context_behavior(["django", "isolated"])
|
||||
|
@ -364,7 +376,14 @@ class DynamicExprTests(BaseTestCase):
|
|||
|
||||
self.assertEqual(
|
||||
rendered.strip(),
|
||||
"<!-- _RENDERED SimpleComponent_6c8e94,a1bc3e -->\n <div> lorem ipsum dolor </div>\n <div> lorem ipsum dolor [{'a': 1}] </div>\n <div> True </div>\n <div> [{'a': 1}, {'a': 2}] </div>\n <div> {'a': 3} </div>", # noqa E501
|
||||
(
|
||||
"<!-- _RENDERED SimpleComponent_6c8e94,a1bc3f,, -->\n"
|
||||
"<div data-djc-id-a1bc3f> lorem ipsum dolor </div>\n"
|
||||
"<div data-djc-id-a1bc3f> lorem ipsum dolor [{'a': 1}] </div>\n"
|
||||
"<div data-djc-id-a1bc3f> True </div>\n"
|
||||
"<div data-djc-id-a1bc3f> [{'a': 1}, {'a': 2}] </div>\n"
|
||||
"<div data-djc-id-a1bc3f> {'a': 3} </div>"
|
||||
),
|
||||
)
|
||||
|
||||
@parametrize_context_behavior(["django", "isolated"])
|
||||
|
@ -408,7 +427,12 @@ class DynamicExprTests(BaseTestCase):
|
|||
|
||||
self.assertEqual(
|
||||
rendered.strip(),
|
||||
'<!-- _RENDERED SimpleComponent_c7a5c3,a1bc3e -->\n <div>"</div>\n <div>{%}</div>\n <div>True</div>', # noqa: E501
|
||||
(
|
||||
"<!-- _RENDERED SimpleComponent_c7a5c3,a1bc3f,, -->\n"
|
||||
'<div data-djc-id-a1bc3f>"</div>\n'
|
||||
"<div data-djc-id-a1bc3f>{%}</div>\n"
|
||||
"<div data-djc-id-a1bc3f>True</div>"
|
||||
),
|
||||
)
|
||||
|
||||
@parametrize_context_behavior(["django", "isolated"])
|
||||
|
@ -457,7 +481,14 @@ class DynamicExprTests(BaseTestCase):
|
|||
|
||||
self.assertEqual(
|
||||
rendered.strip(),
|
||||
"<!-- _RENDERED SimpleComponent_5c8766,a1bc3e -->\n <div><!-- _RENDERED SimpleComponent_5c8766,a1bc3f -->\n <div>3</div>\n <div>True</div>\n </div>\n <div>True</div>", # noqa E501
|
||||
(
|
||||
"<!-- _RENDERED SimpleComponent_5c8766,a1bc41,, -->\n"
|
||||
"<div data-djc-id-a1bc41><!-- _RENDERED SimpleComponent_5c8766,a1bc40,, -->\n"
|
||||
'<div data-djc-id-a1bc40="">3</div>\n'
|
||||
'<div data-djc-id-a1bc40="">True</div>\n'
|
||||
"</div>\n"
|
||||
"<div data-djc-id-a1bc41>True</div>"
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
|
@ -528,11 +559,11 @@ class SpreadOperatorTests(BaseTestCase):
|
|||
self.assertHTMLEqual(
|
||||
rendered,
|
||||
"""
|
||||
<div>LoREM</div>
|
||||
<div>{'@click': '() => {}', 'style': 'height: 20px'}</div>
|
||||
<div>[1, 2, 3]</div>
|
||||
<div>1</div>
|
||||
<div>123</div>
|
||||
<div data-djc-id-a1bc3f>LoREM</div>
|
||||
<div data-djc-id-a1bc3f>{'@click': '() => {}', 'style': 'height: 20px'}</div>
|
||||
<div data-djc-id-a1bc3f>[1, 2, 3]</div>
|
||||
<div data-djc-id-a1bc3f>1</div>
|
||||
<div data-djc-id-a1bc3f>123</div>
|
||||
""",
|
||||
)
|
||||
|
||||
|
@ -665,9 +696,9 @@ class SpreadOperatorTests(BaseTestCase):
|
|||
self.assertHTMLEqual(
|
||||
rendered,
|
||||
"""
|
||||
<div>{'@click': '() => {}', 'style': 'height: 20px'}</div>
|
||||
<div>[1, 2, 3]</div>
|
||||
<div>1</div>
|
||||
<div data-djc-id-a1bc40>{'@click': '() => {}', 'style': 'height: 20px'}</div>
|
||||
<div data-djc-id-a1bc40>[1, 2, 3]</div>
|
||||
<div data-djc-id-a1bc40>1</div>
|
||||
""",
|
||||
)
|
||||
|
||||
|
@ -748,10 +779,10 @@ class SpreadOperatorTests(BaseTestCase):
|
|||
self.assertHTMLEqual(
|
||||
rendered,
|
||||
"""
|
||||
<div>{'@click': '() => {}', 'style': 'OVERWRITTEN'}</div>
|
||||
<div>[1, 2, 3]</div>
|
||||
<div>1</div>
|
||||
<div>OVERWRITTEN_X</div>
|
||||
<div data-djc-id-a1bc3f>{'@click': '() => {}', 'style': 'OVERWRITTEN'}</div>
|
||||
<div data-djc-id-a1bc3f>[1, 2, 3]</div>
|
||||
<div data-djc-id-a1bc3f>1</div>
|
||||
<div data-djc-id-a1bc3f>OVERWRITTEN_X</div>
|
||||
""",
|
||||
)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue