Skip to content

Commit

Permalink
add: expand iterators passed to constructors
Browse files Browse the repository at this point in the history
  • Loading branch information
saemideluxe committed Dec 24, 2024
1 parent 6d13245 commit 513e884
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion htmlgenerator/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 513e884

Please sign in to comment.