Skip to content

Commit 513e884

Browse files
committed
add: expand iterators passed to constructors
1 parent 6d13245 commit 513e884

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

htmlgenerator/base.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import copy
44
import string
5+
import types
56
from typing import Any, Callable, Generator, Iterable, List, Optional, Tuple, Union
67

78
from .lazy import Lazy, resolve_lazy
@@ -57,7 +58,14 @@ def __init__(self, *children):
5758
Uses the given arguments to initialize the list which
5859
represents the child objects
5960
"""
60-
super().__init__(children)
61+
child_elements = []
62+
for c in children:
63+
if isinstance(c, types.GeneratorType):
64+
child_elements.extend(c)
65+
else:
66+
child_elements.append(c)
67+
68+
super().__init__(child_elements)
6169

6270
def render_children(
6371
self, context: dict, stringify: bool = True, fragment: Optional[str] = None

0 commit comments

Comments
 (0)