diff --git a/src/django_components/node.py b/src/django_components/node.py
index bcc61447..3ba28f0b 100644
--- a/src/django_components/node.py
+++ b/src/django_components/node.py
@@ -25,9 +25,11 @@ class BaseNode(Node):
self.kwargs = kwargs or RuntimeKwargs({})
+# NOTE: We consider Nodes to have content only if they have anything else
+# beside whitespace and comments.
def nodelist_has_content(nodelist: NodeList) -> bool:
for node in nodelist:
- if isinstance(node, TextNode) and node.s.isspace():
+ if isinstance(node, TextNode) and (not node.s or node.s.isspace()):
pass
elif isinstance(node, CommentNode):
pass
diff --git a/tests/test_templatetags.py b/tests/test_templatetags.py
index 7eb4e524..b455fed8 100644
--- a/tests/test_templatetags.py
+++ b/tests/test_templatetags.py
@@ -511,3 +511,29 @@ class MultilineTagsTests(BaseTestCase):
Variable: 123
"""
self.assertHTMLEqual(rendered, expected)
+
+
+class NestedTagsTests(BaseTestCase):
+ # See https://github.com/EmilStenstrom/django-components/discussions/671
+ @parametrize_context_behavior(["django", "isolated"])
+ def test_nested_tags(self):
+ @register("test_component")
+ class SimpleComponent(Component):
+ template: types.django_html = """
+ Variable: {{ var }}
+ """
+
+ def get_context_data(self, var):
+ return {
+ "var": var,
+ }
+
+ template: types.django_html = """
+ {% load component_tags %}
+ {% component "test_component" var="{% lorem 1 w %}" %}{% endcomponent %}
+ """
+ rendered = Template(template).render(Context())
+ expected = """
+ Variable: lorem
+ """
+ self.assertHTMLEqual(rendered, expected)