--- a/degal/html.py Wed Jun 10 23:14:37 2009 +0300
+++ b/degal/html.py Wed Jun 10 23:15:14 2009 +0300
@@ -5,7 +5,7 @@
"""
from cgi import escape
-import itertools as _itertools
+import itertools as _itertools, types as _types
class IRenderable (object) :
"""
@@ -90,6 +90,8 @@
Items that are None will be omitted from the return value.
+ Certain core sequence types will be recognized and flattened for output: tuples, lists, and generators.
+
>>> list(Container.process_contents([]))
[]
>>> list(Container.process_contents([None]))
@@ -101,9 +103,14 @@
for content in contents :
if content is None :
continue
-
+
+ # Hardcoded list of special-case nested contents
+ elif isinstance(content, (_types.TupleType, _types.ListType, _types.GeneratorType)) :
+ for subcontent in cls.process_contents(content) :
+ yield subcontent
+
else :
- # normal, handle as unicode data
+ # normal, handle as IRenderable/unicode data
yield content
def __init__ (self, *contents) :