mirror of
https://github.com/django-components/django-components.git
synced 2025-09-26 15:39:08 +00:00
parent
e9fba9538f
commit
4c14675c3a
2 changed files with 22 additions and 1 deletions
|
@ -183,7 +183,7 @@ def do_component(parser, token):
|
||||||
"Component name '%s' should be in quotes" % component_name
|
"Component name '%s' should be in quotes" % component_name
|
||||||
)
|
)
|
||||||
|
|
||||||
component_name = component_name.strip('"')
|
component_name = component_name.strip('"\'')
|
||||||
component_class = registry.get(component_name)
|
component_class = registry.get(component_name)
|
||||||
component = component_class()
|
component = component_class()
|
||||||
|
|
||||||
|
|
|
@ -114,6 +114,15 @@ class ComponentTemplateTagTest(SimpleTestCase):
|
||||||
rendered = template.render(Context({}))
|
rendered = template.render(Context({}))
|
||||||
self.assertHTMLEqual(rendered, "Variable: <strong>variable</strong>\n")
|
self.assertHTMLEqual(rendered, "Variable: <strong>variable</strong>\n")
|
||||||
|
|
||||||
|
def test_component_called_with_singlequoted_name(self):
|
||||||
|
component.registry.register(name="test", component=SimpleComponent)
|
||||||
|
|
||||||
|
template = Template(
|
||||||
|
'{% load component_tags %}{% component \'test\' variable="variable" %}'
|
||||||
|
)
|
||||||
|
rendered = template.render(Context({}))
|
||||||
|
self.assertHTMLEqual(rendered, "Variable: <strong>variable</strong>\n")
|
||||||
|
|
||||||
def test_multiple_component_dependencies(self):
|
def test_multiple_component_dependencies(self):
|
||||||
component.registry.register(name="test1", component=SimpleComponent)
|
component.registry.register(name="test1", component=SimpleComponent)
|
||||||
component.registry.register(name="test2", component=SimpleComponent)
|
component.registry.register(name="test2", component=SimpleComponent)
|
||||||
|
@ -245,3 +254,15 @@ class ComponentSlottedTemplateTagTest(SimpleTestCase):
|
||||||
rendered = template.render(Context({}))
|
rendered = template.render(Context({}))
|
||||||
|
|
||||||
self.assertHTMLEqual(rendered, "<custom-template></custom-template>")
|
self.assertHTMLEqual(rendered, "<custom-template></custom-template>")
|
||||||
|
|
||||||
|
def test_slotted_template_without_slots_an_single_quotes(self):
|
||||||
|
component.registry.register(name="test", component=SlottedComponentNoSlots)
|
||||||
|
template = Template(
|
||||||
|
"""
|
||||||
|
{% load component_tags %}
|
||||||
|
{% component_block 'test' %}{% endcomponent_block %}
|
||||||
|
"""
|
||||||
|
)
|
||||||
|
rendered = template.render(Context({}))
|
||||||
|
|
||||||
|
self.assertHTMLEqual(rendered, "<custom-template></custom-template>")
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue