fix: do NOT render component tags when parsing {% component %} body for fills (#778)

* refactor: do NOT render component tags when parsing {% component %} body for fills

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* refactor: fix typo

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This commit is contained in:
Juro Oravec 2024-11-26 14:52:55 +01:00 committed by GitHub
parent 4d5fecf3ee
commit f5fd3c02cd
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 80 additions and 6 deletions

View file

@ -57,6 +57,7 @@ from django_components.slots import (
SlotName,
SlotRef,
SlotResult,
_is_extracting_fill,
_nodelist_to_slot_render_func,
resolve_fills,
)
@ -894,6 +895,11 @@ class ComponentNode(BaseNode):
def render(self, context: Context) -> str:
trace_msg("RENDR", "COMP", self.name, self.node_id)
# Do not render nested `{% component %}` tags in other `{% component %}` tags
# at the stage when we are determining if the latter has named fills or not.
if _is_extracting_fill(context):
return ""
component_cls: Type[Component] = self.registry.get(self.name)
# Resolve FilterExpressions and Variables that were passed as args to the