Remove component tag in favour of component_block.

This commit is contained in:
Emil Stenström 2024-02-11 22:08:35 +01:00 committed by Emil Stenström
parent f3350ced11
commit ef6a082238
12 changed files with 101 additions and 108 deletions

View file

@ -7,7 +7,7 @@ A way to create simple reusable template components in Django.
It lets you create "template components", that contains both the template, the Javascript and the CSS needed to generate the front end code you need for a modern app. Components look like this:
```htmldjango
{% component "calendar" date="2015-06-19" %}
{% component_block "calendar" date="2015-06-19" %}{% endcomponent_block %}
```
And this is what gets rendered (plus the CSS and Javascript you've specified):
@ -220,7 +220,7 @@ First load the `component_tags` tag library, then use the `component_[js/css]_de
{% component_css_dependencies %}
</head>
<body>
{% component "calendar" date="2015-06-19" %}
{% component_block "calendar" date="2015-06-19" %}{% endcomponent_block %}
{% component_js_dependencies %}
</body>
<html>
@ -614,10 +614,10 @@ COMPONENTS = {
## Component context and scope
By default, components can access context variables from the parent template, just like templates that are included with the `{% include %}` tag. Just like with `{% include %}`, if you don't want the component template to have access to the parent context, add `only` to the end of the `{% component %}` (or `{% component_block %}` tag):
By default, components can access context variables from the parent template, just like templates that are included with the `{% include %}` tag. Just like with `{% include %}`, if you don't want the component template to have access to the parent context, add `only` to the end of the `{% component_block %}` (or `{% component_block %}{% endcomponent_block %}` tag):
```htmldjango
{% component "calendar" date="2015-06-19" only %}
{% component_block "calendar" date="2015-06-19" only %}{% endcomponent_block %}
```
NOTE: `{% csrf_token %}` tags need access to the top-level context, and they will not function properly if they are rendered in a component that is called with the `only` modifier.

View file

@ -92,7 +92,7 @@ class RenderBenchmarks(SimpleTestCase):
def test_render_time_for_small_component(self):
template = Template(
"{% load component_tags %}{% component_block 'test_component' %}"
"{% slot \"header\" %}{% component 'inner_component' variable='foo' %}{% endslot %}"
"{% slot \"header\" %}{% component_block 'inner_component' variable='foo' %}{% endslot %}{% endcomponent_block %}"
"{% endcomponent_block %}",
name="root",
)
@ -105,7 +105,7 @@ class RenderBenchmarks(SimpleTestCase):
template = Template(
"{% load component_tags %}{% component_dependencies %}"
"{% component_block 'test_component' %}{% slot \"header\" %}"
"{% component 'inner_component' variable='foo' %}{% endslot %}{% endcomponent_block %}",
"{% component_block 'inner_component' variable='foo' %}{% endslot %}{% endcomponent_block %}{% endcomponent_block %}",
name="root",
)
# Sanity tests

View file

@ -253,7 +253,7 @@ class Component(View, metaclass=SimplifiedInterfaceMediaDefiningClass):
# can be invoked with implicit filling.
if default_fill_content and not default_slot_encountered:
raise TemplateSyntaxError(
f"Component '{self.registered_name}' passed default fill content "
f"Component '{self.registered_name}' passed default fill content '{default_fill_content}'"
f"(i.e. without explicit 'fill' tag), "
f"even though none of its slots is marked as 'default'."
)

View file

@ -151,23 +151,6 @@ def component_js_dependencies_tag(preload=""):
return mark_safe("\n".join(rendered_dependencies))
@register.tag(name="component")
def do_component(parser, token):
bits = token.split_contents()
bits, isolated_context = check_for_isolated_context_keyword(bits)
component_name, context_args, context_kwargs = parse_component_with_args(
parser, bits, "component"
)
return ComponentNode(
FilterExpression(component_name, parser),
context_args,
context_kwargs,
isolated_context=isolated_context,
)
class UserSlotVar:
"""
Extensible mechanism for offering 'fill' blocks in template access to properties

View file

@ -5,7 +5,7 @@
{% component_css_dependencies %}
</head>
<body>
{% component "calendar" date=date %}
{% component_block "calendar" date=date %}{% endcomponent_block %}
{% component_block "greeting" name='Joe' %}
{% fill "message" %}
Howdy?

View file

@ -200,7 +200,7 @@ Page lightly modified and partially extracted as a component #}
</div>
</header>
<div class="titlebar-container"><h1 class="title">Document and website structure</h1></div>
{% component 'breadcrumb_component' items=5 %}
{% component_block 'breadcrumb_component' items=5 %}{% endcomponent_block %}
<div class="locale-container">
<form class="language-menu"><label for="select_language" class="visually-hidden">Select your preferred
language</label> <select id="select_language" name="language">

View file

@ -2,11 +2,11 @@
<div>
<h1>Parent content</h1>
{% component name="variable_display" shadowing_variable='override' new_variable='unique_val' %}
{% component_block name="variable_display" shadowing_variable='override' new_variable='unique_val' %}{% endcomponent_block %}
</div>
<div>
{% slot 'content' %}
<h2>Slot content</h2>
{% component name="variable_display" shadowing_variable='slot_default_override' new_variable='slot_default_unique' %}
{% component_block name="variable_display" shadowing_variable='slot_default_override' new_variable='slot_default_unique' %}{% endcomponent_block %}
{% endslot %}
</div>

View file

@ -2,11 +2,11 @@
<div>
<h1>Parent content</h1>
{% component name="variable_display" shadowing_variable=inner_parent_value new_variable='unique_val' %}
{% component_block name="variable_display" shadowing_variable=inner_parent_value new_variable='unique_val' %}{% endcomponent_block %}
</div>
<div>
{% slot 'content' %}
<h2>Slot content</h2>
{% component name="variable_display" shadowing_variable='slot_default_override' new_variable=inner_parent_value %}
{% component_block name="variable_display" shadowing_variable='slot_default_override' new_variable=inner_parent_value %}{% endcomponent_block %}
{% endslot %}
</div>

View file

@ -89,7 +89,7 @@ def render_template_view(request):
template = Template(
"""
{% load component_tags %}
{% component "testcomponent" variable="TEMPLATE" %}
{% component_block "testcomponent" variable="TEMPLATE" %}{% endcomponent_block %}
"""
)
return HttpResponse(template.render(Context({})))

View file

@ -82,7 +82,7 @@ class ContextTests(SimpleTestCase):
):
template = Template(
"{% load component_tags %}{% component_dependencies %}"
"{% component 'parent_component' %}"
"{% component_block 'parent_component' %}{% endcomponent_block %}"
)
rendered = template.render(Context())
@ -103,7 +103,7 @@ class ContextTests(SimpleTestCase):
):
template = Template(
"{% load component_tags %}{% component_dependencies %}"
"{% component name='parent_component' %}"
"{% component_block name='parent_component' %}{% endcomponent_block %}"
)
rendered = template.render(Context())
@ -156,13 +156,15 @@ class ContextTests(SimpleTestCase):
)
def test_nested_component_context_shadows_parent_with_filled_slots(self):
template = Template(
"{% load component_tags %}{% component_dependencies %}"
"{% component_block 'parent_component' %}"
"{% fill 'content' %}{% component name='variable_display' "
"shadowing_variable='shadow_from_slot' new_variable='unique_from_slot' %}{% endfill %}"
"{% endcomponent_block %}"
)
template = Template("""
{% load component_tags %}{% component_dependencies %}
{% component_block 'parent_component' %}
{% fill 'content' %}
{% component_block name='variable_display' shadowing_variable='shadow_from_slot' new_variable='unique_from_slot' %}
{% endcomponent_block %}
{% endfill %}
{% endcomponent_block %}
""") # NOQA
rendered = template.render(Context())
self.assertIn(
@ -180,13 +182,15 @@ class ContextTests(SimpleTestCase):
def test_nested_component_instances_have_unique_context_with_filled_slots(
self,
):
template = Template(
"{% load component_tags %}{% component_dependencies %}"
"{% component_block 'parent_component' %}"
"{% fill 'content' %}{% component name='variable_display' "
"shadowing_variable='shadow_from_slot' new_variable='unique_from_slot' %}{% endfill %}"
"{% endcomponent_block %}"
)
template = Template("""
{% load component_tags %}{% component_dependencies %}
{% component_block 'parent_component' %}
{% fill 'content' %}
{% component_block name='variable_display' shadowing_variable='shadow_from_slot' new_variable='unique_from_slot' %}
{% endcomponent_block %}
{% endfill %}
{% endcomponent_block %}
""") # NOQA
rendered = template.render(Context())
self.assertIn(
@ -203,7 +207,7 @@ class ContextTests(SimpleTestCase):
):
template = Template(
"{% load component_tags %}{% component_dependencies %}"
"{% component name='parent_component' %}"
"{% component_block name='parent_component' %}{% endcomponent_block %}"
)
rendered = template.render(
Context({"shadowing_variable": "NOT SHADOWED"})
@ -247,13 +251,15 @@ class ContextTests(SimpleTestCase):
def test_nested_component_context_shadows_outer_context_with_filled_slots(
self,
):
template = Template(
"{% load component_tags %}{% component_dependencies %}"
"{% component_block 'parent_component' %}"
"{% fill 'content' %}{% component name='variable_display' "
"shadowing_variable='shadow_from_slot' new_variable='unique_from_slot' %}{% endfill %}"
"{% endcomponent_block %}"
)
template = Template("""
{% load component_tags %}{% component_dependencies %}
{% component_block 'parent_component' %}
{% fill 'content' %}
{% component_block name='variable_display' shadowing_variable='shadow_from_slot' new_variable='unique_from_slot' %}
{% endcomponent_block %}
{% endfill %}
{% endcomponent_block %}
""") # NOQA
rendered = template.render(
Context({"shadowing_variable": "NOT SHADOWED"})
)
@ -308,13 +314,15 @@ class ParentArgsTests(SimpleTestCase):
)
def test_parent_args_available_in_slots(self):
template = Template(
"{% load component_tags %}{% component_dependencies %}"
"{% component_block 'parent_with_args' parent_value='passed_in' %}"
"{% fill 'content' %}{% component name='variable_display' "
"shadowing_variable='value_from_slot' new_variable=inner_parent_value %}{% endfill %}"
"{%endcomponent_block %}"
)
template = Template("""
{% load component_tags %}{% component_dependencies %}
{% component_block 'parent_with_args' parent_value='passed_in' %}
{% fill 'content' %}
{% component_block name='variable_display' shadowing_variable='value_from_slot' new_variable=inner_parent_value %}
{% endcomponent_block %}
{% endfill %}
{% endcomponent_block %}
""") # NOQA
rendered = template.render(Context())
self.assertIn(
@ -332,7 +340,7 @@ class ContextCalledOnceTests(SimpleTestCase):
def test_one_context_call_with_simple_component(self):
template = Template(
"{% load component_tags %}{% component_dependencies %}"
"{% component name='incrementer' %}"
"{% component_block name='incrementer' %}{% endcomponent_block %}"
)
rendered = template.render(Context()).strip()
@ -342,7 +350,7 @@ class ContextCalledOnceTests(SimpleTestCase):
def test_one_context_call_with_simple_component_and_arg(self):
template = Template(
"{% load component_tags %}{% component name='incrementer' value='2' %}"
"{% load component_tags %}{% component_block name='incrementer' value='2' %}{% endcomponent_block %}"
)
rendered = template.render(Context()).strip()
@ -405,7 +413,7 @@ class ComponentsCanAccessOuterContext(SimpleTestCase):
def test_simple_component_can_use_outer_context(self):
template = Template(
"{% load component_tags %}{% component_dependencies %}"
"{% component 'simple_component' %}"
"{% component_block 'simple_component' %}{% endcomponent_block %}"
)
rendered = template.render(
Context({"variable": "outer_value"})
@ -417,7 +425,7 @@ class IsolatedContextTests(SimpleTestCase):
def test_simple_component_can_pass_outer_context_in_args(self):
template = Template(
"{% load component_tags %}{% component_dependencies %}"
"{% component 'simple_component' variable only %}"
"{% component_block 'simple_component' variable only %}{% endcomponent_block %}"
)
rendered = template.render(
Context({"variable": "outer_value"})
@ -427,7 +435,7 @@ class IsolatedContextTests(SimpleTestCase):
def test_simple_component_cannot_use_outer_context(self):
template = Template(
"{% load component_tags %}{% component_dependencies %}"
"{% component 'simple_component' only %}"
"{% component_block 'simple_component' only %}{% endcomponent_block %}"
)
rendered = template.render(
Context({"variable": "outer_value"})
@ -452,7 +460,7 @@ class IsolatedContextSettingTests(SimpleTestCase):
):
template = Template(
"{% load component_tags %}{% component_dependencies %}"
"{% component 'simple_component' variable %}"
"{% component_block 'simple_component' variable %}{% endcomponent_block %}"
)
rendered = template.render(Context({"variable": "outer_value"}))
self.assertIn("outer_value", rendered, rendered)
@ -462,7 +470,7 @@ class IsolatedContextSettingTests(SimpleTestCase):
):
template = Template(
"{% load component_tags %}{% component_dependencies %}"
"{% component 'simple_component' %}"
"{% component_block 'simple_component' %}{% endcomponent_block %}"
)
rendered = template.render(Context({"variable": "outer_value"}))
self.assertNotIn("outer_value", rendered, rendered)
@ -494,7 +502,7 @@ class OuterContextPropertyTests(SimpleTestCase):
def test_outer_context_property_with_component(self):
template = Template(
"{% load component_tags %}{% component_dependencies %}"
"{% component 'outer_context_component' only %}"
"{% component_block 'outer_context_component' only %}{% endcomponent_block %}"
)
rendered = template.render(
Context({"variable": "outer_value"})

View file

@ -117,7 +117,7 @@ class ComponentMediaRenderingTests(SimpleTestCase):
template = Template(
"{% load component_tags %}{% component_dependencies %}"
"{% component 'test' variable='foo' %}"
"{% component_block 'test' variable='foo' %}{% endcomponent_block %}"
)
rendered = create_and_process_template_response(template)
self.assertInHTML(
@ -132,7 +132,7 @@ class ComponentMediaRenderingTests(SimpleTestCase):
template = Template(
"{% load component_tags %}{% component_dependencies %}"
"{% component 'test' variable='foo' %}"
"{% component_block 'test' variable='foo' %}{% endcomponent_block %}"
)
rendered = create_and_process_template_response(template)
self.assertInHTML(
@ -147,7 +147,7 @@ class ComponentMediaRenderingTests(SimpleTestCase):
template = Template(
"{% load component_tags %}{% component_dependencies preload='test' %}"
"{% component 'test' variable='foo' %}"
"{% component_block 'test' variable='foo' %}{% endcomponent_block %}"
)
rendered = create_and_process_template_response(template)
self.assertInHTML(
@ -162,7 +162,7 @@ class ComponentMediaRenderingTests(SimpleTestCase):
template = Template(
"{% load component_tags %}{% component_dependencies %}"
"{% component 'test' variable='foo' %}"
"{% component_block 'test' variable='foo' %}{% endcomponent_block %}"
)
rendered = create_and_process_template_response(template)
self.assertNotIn("_RENDERED", rendered)
@ -181,7 +181,7 @@ class ComponentMediaRenderingTests(SimpleTestCase):
template = Template(
"{% load component_tags %}{% component_css_dependencies %}"
"{% component 'test' variable='foo' %}"
"{% component_block 'test' variable='foo' %}{% endcomponent_block %}"
)
rendered = create_and_process_template_response(template)
self.assertInHTML(
@ -195,7 +195,7 @@ class ComponentMediaRenderingTests(SimpleTestCase):
template = Template(
"{% load component_tags %}{% component_js_dependencies %}"
"{% component 'test' variable='foo' %}"
"{% component_block 'test' variable='foo' %}{% endcomponent_block %}"
)
rendered = create_and_process_template_response(template)
self.assertInHTML('<script src="script.js">', rendered, count=1)
@ -205,7 +205,7 @@ class ComponentMediaRenderingTests(SimpleTestCase):
):
component.registry.register(name="test", component=MultistyleComponent)
template = Template(
"{% load component_tags %}{% component_dependencies %}{% component 'test' %}"
"{% load component_tags %}{% component_dependencies %}{% component_block 'test' %}{% endcomponent_block %}"
)
rendered = create_and_process_template_response(template)
self.assertInHTML('<script src="script.js">', rendered, count=1)
@ -226,7 +226,7 @@ class ComponentMediaRenderingTests(SimpleTestCase):
):
component.registry.register(name="test", component=MultistyleComponent)
template = Template(
"{% load component_tags %}{% component_js_dependencies %}{% component 'test' %}"
"{% load component_tags %}{% component_js_dependencies %}{% component_block 'test' %}{% endcomponent_block %}"
)
rendered = create_and_process_template_response(template)
self.assertInHTML('<script src="script.js">', rendered, count=1)
@ -247,7 +247,7 @@ class ComponentMediaRenderingTests(SimpleTestCase):
):
component.registry.register(name="test", component=MultistyleComponent)
template = Template(
"{% load component_tags %}{% component_css_dependencies %}{% component 'test' %}"
"{% load component_tags %}{% component_css_dependencies %}{% component_block 'test' %}{% endcomponent_block %}"
)
rendered = create_and_process_template_response(template)
self.assertInHTML('<script src="script.js">', rendered, count=0)
@ -294,7 +294,7 @@ class ComponentMediaRenderingTests(SimpleTestCase):
template = Template(
"{% load component_tags %}{% component_css_dependencies %}"
"{% component 'test1' 'variable' %}"
"{% component_block 'test1' 'variable' %}{% endcomponent_block %}"
)
rendered = create_and_process_template_response(template)
self.assertInHTML(
@ -316,7 +316,7 @@ class ComponentMediaRenderingTests(SimpleTestCase):
template = Template(
"{% load component_tags %}{% component_js_dependencies %}"
"{% component 'test1' 'variable' %}"
"{% component_block 'test1' 'variable' %}{% endcomponent_block %}"
)
rendered = create_and_process_template_response(template)
self.assertInHTML('<script src="script.js">', rendered, count=1)
@ -330,7 +330,7 @@ class ComponentMediaRenderingTests(SimpleTestCase):
template = Template(
"{% load component_tags %}{% component_dependencies %}"
"{% component 'test2' variable='variable' %}"
"{% component_block 'test2' variable='variable' %}{% endcomponent_block %}"
)
rendered = create_and_process_template_response(template)
self.assertInHTML('<script src="script.js">', rendered, count=0)
@ -355,11 +355,12 @@ class ComponentMediaRenderingTests(SimpleTestCase):
name="test3", component=SimpleComponentWithSharedDependency
)
template = Template(
"{% load component_tags %}{% component_dependencies %}"
"{% component 'test1' variable='variable' %}{% component 'test2' variable='variable' %}"
"{% component 'test1' variable='variable' %}"
)
template = Template("""
{% load component_tags %}{% component_dependencies %}
{% component_block 'test1' variable='variable' %}{% endcomponent_block %}
{% component_block 'test2' variable='variable' %}{% endcomponent_block %}
{% component_block 'test1' variable='variable' %}{% endcomponent_block %}
""")
rendered = create_and_process_template_response(template)
self.assertInHTML('<script src="script.js">', rendered, count=1)
self.assertInHTML('<script src="script2.js">', rendered, count=1)
@ -383,11 +384,12 @@ class ComponentMediaRenderingTests(SimpleTestCase):
name="test3", component=SimpleComponentWithSharedDependency
)
template = Template(
"{% load component_tags %}{% component_dependencies %}"
"{% component 'test1' variable='variable' %}{% component 'test2' variable='variable' %}"
"{% component 'test1' variable='variable' %}"
)
template = Template("""
{% load component_tags %}{% component_dependencies %}
{% component_block 'test1' variable='variable' %}{% endcomponent_block %}
{% component_block 'test2' variable='variable' %}{% endcomponent_block %}
{% component_block 'test1' variable='variable' %}{% endcomponent_block %}
""")
rendered = create_and_process_template_response(template)
self.assertNotIn("_RENDERED", rendered)
@ -415,7 +417,7 @@ class ComponentMediaRenderingTests(SimpleTestCase):
"{% load component_tags %}"
"{% component_js_dependencies %}"
"{% component_css_dependencies %}"
f"{{% component '{component_name}' variable='value' %}}"
f"{{% component_block '{component_name}' variable='value' %}}{{% endcomponent_block %}}"
)
rendered = create_and_process_template_response(template)
self.assertHTMLEqual(

View file

@ -92,7 +92,7 @@ class ComponentTemplateTagTest(SimpleTestCase):
def inline_to_block(self, tag):
return re.sub(
r"({% component (.*) %})",
r"({% component_block (.*) %}{% endcomponent_block %})",
r"{% component_block \2 %}{% endcomponent_block %}",
tag,
)
@ -100,7 +100,7 @@ class ComponentTemplateTagTest(SimpleTestCase):
def test_single_component(self):
component.registry.register(name="test", component=SimpleComponent)
simple_tag_tempate = '{% load component_tags %}{% component name="test" variable="variable" %}'
simple_tag_tempate = '{% load component_tags %}{% component_block name="test" variable="variable" %}{% endcomponent_block %}'
block_tag_template = self.inline_to_block(simple_tag_tempate)
for tag in [simple_tag_tempate, block_tag_template]:
@ -113,7 +113,7 @@ class ComponentTemplateTagTest(SimpleTestCase):
def test_call_with_invalid_name(self):
# Note: No tag registered
simple_tag_tempate = '{% load component_tags %}{% component name="test" variable="variable" %}'
simple_tag_tempate = '{% load component_tags %}{% component_block name="test" variable="variable" %}{% endcomponent_block %}'
block_tag_template = self.inline_to_block(simple_tag_tempate)
for tag in [simple_tag_tempate, block_tag_template]:
@ -126,7 +126,7 @@ class ComponentTemplateTagTest(SimpleTestCase):
def test_component_called_with_positional_name(self):
component.registry.register(name="test", component=SimpleComponent)
simple_tag_tempate = '{% load component_tags %}{% component "test" variable="variable" %}'
simple_tag_tempate = '{% load component_tags %}{% component_block "test" variable="variable" %}{% endcomponent_block %}'
block_tag_template = self.inline_to_block(simple_tag_tempate)
for tag in [simple_tag_tempate, block_tag_template]:
@ -141,7 +141,7 @@ class ComponentTemplateTagTest(SimpleTestCase):
simple_tag_tempate = """
{% load component_tags %}
{% component name="test" variable="variable" variable2="hej" %}
{% component_block name="test" variable="variable" variable2="hej" %}{% endcomponent_block %}
"""
block_tag_template = self.inline_to_block(simple_tag_tempate)
@ -157,7 +157,7 @@ class ComponentTemplateTagTest(SimpleTestCase):
def test_component_called_with_singlequoted_name(self):
component.registry.register(name="test", component=SimpleComponent)
simple_tag_tempate = """{% load component_tags %}{% component 'test' variable="variable" %}"""
simple_tag_tempate = """{% load component_tags %}{% component_block 'test' variable="variable" %}{% endcomponent_block %}"""
block_tag_template = self.inline_to_block(simple_tag_tempate)
for tag in [simple_tag_tempate, block_tag_template]:
@ -173,7 +173,7 @@ class ComponentTemplateTagTest(SimpleTestCase):
simple_tag_tempate = """
{% load component_tags %}
{% with component_name="test" %}
{% component component_name variable="variable" %}
{% component_block component_name variable="variable" %}{% endcomponent_block %}
{% endwith %}
"""
block_tag_template = self.inline_to_block(simple_tag_tempate)
@ -191,7 +191,7 @@ class ComponentTemplateTagTest(SimpleTestCase):
simple_tag_tempate = """
{% load component_tags %}
{% with component_name="BLAHONGA" %}
{% component component_name variable="variable" %}
{% component_block component_name variable="variable" %}{% endcomponent_block %}
{% endwith %}
"""
block_tag_template = self.inline_to_block(simple_tag_tempate)
@ -222,7 +222,7 @@ class ComponentSlottedTemplateTagTest(SimpleTestCase):
Custom header
{% endfill %}
{% fill "main" %}
{% component "test2" variable="variable" %}
{% component_block "test2" variable="variable" %}{% endcomponent_block %}
{% endfill %}
{% endcomponent_block %}
"""
@ -700,7 +700,7 @@ class TemplateInstrumentationTest(SimpleTestCase):
template = Template(
"""
{% load component_tags %}
{% component 'test_component' %}
{% component_block 'test_component' %}{% endcomponent_block %}
""",
name="root",
)
@ -713,7 +713,7 @@ class TemplateInstrumentationTest(SimpleTestCase):
{% load component_tags %}
{% component_block 'test_component' %}
{% fill "header" %}
{% component 'inner_component' variable='foo' %}
{% component_block 'inner_component' variable='foo' %}{% endcomponent_block %}
{% endfill %}
{% endcomponent_block %}
""",
@ -818,8 +818,8 @@ class ConditionalSlotTests(SimpleTestCase):
template = Template(
"""
{% load component_tags %}
{% component 'test' branch='a' %}
{% component 'test' branch='b' %}
{% component_block 'test' branch='a' %}{% endcomponent_block %}
{% component_block 'test' branch='b' %}{% endcomponent_block %}
"""
)
rendered = template.render(Context({}))
@ -1076,7 +1076,7 @@ class ComponentNestingTests(SimpleTestCase):
template = Template(
"""
{% load component_tags %}
{% component "dashboard" %}
{% component_block "dashboard" %}{% endcomponent_block %}
"""
)
rendered = template.render(Context({"items": [1, 2, 3]}))
@ -1160,7 +1160,7 @@ class ConditionalIfFilledSlotsTests(SimpleTestCase):
def test_simple_component_with_conditional_slot(self):
template = """
{% load component_tags %}
{% component "conditional_slots" %}
{% component_block "conditional_slots" %}{% endcomponent_block %}
"""
expected = """
<div class="frontmatter-component">