unpack tuple in itertag

This commit is contained in:
Lendemor 2025-02-06 23:38:58 +01:00
parent 460ad89ffe
commit a35c1b71a4

View File

@ -130,10 +130,14 @@ class IterTag(Tag):
raise ValueError("The render function must take 2 arguments.")
component = self.render_fn(arg, index)
# Nested foreach components, cond and tuples must be wrapped in fragments.
if isinstance(component, (Foreach, Cond, tuple)):
# Nested foreach components, cond must be wrapped in fragments.
if isinstance(component, (Foreach, Cond)):
component = Fragment.create(component)
# If the component is a tuple, unpack and wrap it in a fragment.
if isinstance(component, tuple):
component = Fragment.create(*component)
# Set the component key.
if component.key is None:
component.key = index