diff --git a/htmlgenerator/base.py b/htmlgenerator/base.py index a39a033..159dd28 100644 --- a/htmlgenerator/base.py +++ b/htmlgenerator/base.py @@ -2,6 +2,7 @@ import copy import string +import types from typing import Any, Callable, Generator, Iterable, List, Optional, Tuple, Union from .lazy import Lazy, resolve_lazy @@ -57,7 +58,14 @@ def __init__(self, *children): Uses the given arguments to initialize the list which represents the child objects """ - super().__init__(children) + child_elements = [] + for c in children: + if isinstance(c, types.GeneratorType): + child_elements.extend(c) + else: + child_elements.append(c) + + super().__init__(child_elements) def render_children( self, context: dict, stringify: bool = True, fragment: Optional[str] = None