mirror of
https://github.com/django-components/django-components.git
synced 2025-08-04 14:28:18 +00:00
Only render dependencies that are used of a specific page (#52)
Co-authored-by: rbeard0330 <@dul2k3BKW6m>
This commit is contained in:
parent
cc8db8056e
commit
57a5aa0f4b
11 changed files with 2576 additions and 99 deletions
|
@ -215,28 +215,27 @@ class ContextCalledOnceTests(SimpleTestCase):
|
|||
self.assertEqual(rendered, '<p class="incrementer">value=1;calls=1</p>', rendered)
|
||||
|
||||
def test_one_context_call_with_simple_component_and_arg(self):
|
||||
template = Template("{% load component_tags %}{% component_dependencies %}"
|
||||
"{% component name='incrementer' value='2' %}")
|
||||
template = Template("{% load component_tags %}{% component name='incrementer' value='2' %}")
|
||||
rendered = template.render(Context()).strip()
|
||||
|
||||
self.assertEqual(rendered, '<p class="incrementer">value=3;calls=1</p>', rendered)
|
||||
|
||||
def test_one_context_call_with_component_block(self):
|
||||
template = Template("{% load component_tags %}{% component_dependencies %}"
|
||||
template = Template("{% load component_tags %}"
|
||||
"{% component_block 'incrementer' %}{% endcomponent_block %}")
|
||||
rendered = template.render(Context()).strip()
|
||||
|
||||
self.assertEqual(rendered, '<p class="incrementer">value=1;calls=1</p>', rendered)
|
||||
|
||||
def test_one_context_call_with_component_block_and_arg(self):
|
||||
template = Template("{% load component_tags %}{% component_dependencies %}"
|
||||
template = Template("{% load component_tags %}"
|
||||
"{% component_block 'incrementer' value='3' %}{% endcomponent_block %}")
|
||||
rendered = template.render(Context()).strip()
|
||||
|
||||
self.assertEqual(rendered, '<p class="incrementer">value=4;calls=1</p>', rendered)
|
||||
|
||||
def test_one_context_call_with_slot(self):
|
||||
template = Template("{% load component_tags %}{% component_dependencies %}"
|
||||
template = Template("{% load component_tags %}"
|
||||
"{% component_block 'incrementer' %}{% slot 'content' %}"
|
||||
"<p>slot</p>{% endslot %}{% endcomponent_block %}")
|
||||
rendered = template.render(Context()).strip()
|
||||
|
@ -244,7 +243,7 @@ class ContextCalledOnceTests(SimpleTestCase):
|
|||
self.assertEqual(rendered, '<p class="incrementer">value=1;calls=1</p>\n<p>slot</p>', rendered)
|
||||
|
||||
def test_one_context_call_with_slot_and_arg(self):
|
||||
template = Template("{% load component_tags %}{% component_dependencies %}"
|
||||
template = Template("{% load component_tags %}"
|
||||
"{% component_block 'incrementer' value='3' %}{% slot 'content' %}"
|
||||
"<p>slot</p>{% endslot %}{% endcomponent_block %}")
|
||||
rendered = template.render(Context()).strip()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue