mirror of
https://github.com/django-components/django-components.git
synced 2025-11-25 08:21:20 +00:00
This commit is contained in:
parent
6fcddccd6c
commit
7544bd10e2
4 changed files with 67 additions and 1 deletions
6
.gitignore
vendored
6
.gitignore
vendored
|
|
@ -65,3 +65,9 @@ target/
|
|||
# as project supports variety of Django versions
|
||||
poetry.lock
|
||||
pyproject.toml
|
||||
|
||||
# PyCharm
|
||||
.idea/
|
||||
|
||||
# Python environment
|
||||
.venv/
|
||||
|
|
|
|||
12
tests/templates/extendable_template_with_blocks.html
Normal file
12
tests/templates/extendable_template_with_blocks.html
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
{% load component_tags %}
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<body>
|
||||
<main role="main">
|
||||
<div class='container main-container'>
|
||||
{% block body %}
|
||||
{% endblock %}
|
||||
</div>
|
||||
</main>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -1,2 +1,3 @@
|
|||
{% load component_tags %}<p class="incrementer">value={{ value }};calls={{ calls }}</p>
|
||||
{% load component_tags %}
|
||||
<p class="incrementer">value={{ value }};calls={{ calls }}</p>
|
||||
{% slot 'content' %}{% endslot %}
|
||||
|
|
@ -1055,3 +1055,50 @@ class ConditionalIfFilledSlotsTests(SimpleTestCase):
|
|||
"""
|
||||
rendered = Template(template).render(Context({}))
|
||||
self.assertHTMLEqual(rendered, expected)
|
||||
|
||||
|
||||
class RegressionTests(SimpleTestCase):
|
||||
"""Ensure we don't break the same thing AGAIN."""
|
||||
|
||||
def setUp(self):
|
||||
component.registry.clear()
|
||||
super().setUp()
|
||||
|
||||
@classmethod
|
||||
def tearDownClass(cls):
|
||||
super().tearDownClass()
|
||||
component.registry.clear()
|
||||
|
||||
def test_extends_tag_works(self):
|
||||
component.registry.register("slotted_component", SlottedComponent)
|
||||
template = """
|
||||
{% extends "extendable_template_with_blocks.html" %}
|
||||
{% load component_tags %}
|
||||
{% block body %}
|
||||
{% component_block "slotted_component" %}
|
||||
{% fill "header" %}{% endfill %}
|
||||
{% fill "main" %}
|
||||
TEST
|
||||
{% endfill %}
|
||||
{% fill "footer" %}{% endfill %}
|
||||
{% endcomponent_block %}
|
||||
{% endblock %}
|
||||
"""
|
||||
rendered = Template(template).render(Context())
|
||||
expected = """
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<body>
|
||||
<main role="main">
|
||||
<div class='container main-container'>
|
||||
<custom-template>
|
||||
<header></header>
|
||||
<main>TEST</main>
|
||||
<footer></footer>
|
||||
</custom-template>
|
||||
</div>
|
||||
</main>
|
||||
</body>
|
||||
</html>
|
||||
"""
|
||||
self.assertHTMLEqual(rendered, expected)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue