Commits

jason kirtland committed 36fd36b

Handle nested streams when simplifying (oddly difficult to cover with tests.)

  • Participants
  • Parent commits fbef118

Comments (0)

Files changed (2)

File flatland/out/genshi_06.py

 
     new_contents = transform(tagname.localname, mutable_attrs, contents,
                              render_context, bind)
+
     if new_contents is None:
         new_contents = ()
     elif isinstance(new_contents, unicode):
             value = _eval_expr(data, ctxt, vars)
             if hasattr(value, '__html__'):
                 value = value.__html__()
+            elif hasattr(value, '__next__') or hasattr(value, 'next'):
+                value = _simplify_stream(value, ctxt, vars)
             elif not isinstance(value, unicode):
                 value = unicode(value)
             parts.append(value)

File tests/markup/test_genshi_06.py

     assert rendered == expected
 
 
+def test_stream_preserved():
+    markup = """\
+<py:def function="fn()"><b>yowza!</b></py:def>
+<button form:bind="form">
+  <em>wow!</em> ${fn()} ${1 + 1}
+</button>
+"""
+    expected = """\
+<button name="element" value="">
+  <em>wow!</em> <b>yowza!</b> 2
+</button>"""
+
+    rendered = render(markup, 'xhtml', schema)
+    assert rendered == expected
+
+
 def test_tortured_select():
     markup = """\
 <select form:bind="form">