fix: loader tags compatibility (#468)

This commit is contained in:
Juro Oravec 2024-05-02 22:24:49 +02:00 committed by GitHub
parent eef331e903
commit e566d8ecbb
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
11 changed files with 592 additions and 22 deletions

View file

@ -9,6 +9,7 @@ from django.forms.widgets import Media, MediaDefiningClass
from django.http import HttpResponse
from django.template.base import FilterExpression, Node, NodeList, Template, TextNode
from django.template.context import Context
from django.template.exceptions import TemplateSyntaxError
from django.template.loader import get_template
from django.utils.html import escape
from django.utils.safestring import SafeString, mark_safe
@ -291,6 +292,7 @@ class Component(View, metaclass=SimplifiedInterfaceMediaDefiningClass):
context_data = {}
slots, resolved_fills = resolve_slots(
context,
template,
component_name=self.registered_name,
context_data=context_data,
@ -402,6 +404,12 @@ class ComponentNode(Node):
# Note that outer component context is used to resolve variables in
# fill tag.
resolved_name = fill_node.name_fexp.resolve(context)
if resolved_name in fill_content:
raise TemplateSyntaxError(
f"Multiple fill tags cannot target the same slot name: "
f"Detected duplicate fill tag name '{resolved_name}'."
)
resolved_fill_alias = fill_node.resolve_alias(context, resolved_component_name)
fill_content[resolved_name] = FillContent(fill_node.nodelist, resolved_fill_alias)