# HG changeset patch # User jruigrok # Date 1292267279 0 # Node ID 3c09c8d8a57880e6f9c4b65aeacbaf497a6bffc4 # Parent 8cef75b02ac1aeb922c3bf2ca0e7d09651abe5dd Pull up r1146 to trunk. Addresses #399 diff --git a/genshi/template/markup.py b/genshi/template/markup.py --- a/genshi/template/markup.py +++ b/genshi/template/markup.py @@ -308,8 +308,7 @@ """ match_templates = ctxt._match_templates - tail = [] - def _strip(stream, append=tail.append): + def _strip(stream, append): depth = 1 next = stream.next while 1: @@ -353,7 +352,8 @@ pre_end = idx + 1 if 'match_once' not in hints and 'not_recursive' in hints: pre_end -= 1 - inner = _strip(stream) + tail = [] + inner = _strip(stream, tail.append) if pre_end > 0: inner = self._match(inner, ctxt, start=start, end=pre_end, **vars) diff --git a/genshi/template/tests/markup.py b/genshi/template/tests/markup.py --- a/genshi/template/tests/markup.py +++ b/genshi/template/tests/markup.py @@ -732,6 +732,30 @@ """, tmpl.generate().render(encoding=None)) + def test_match_tail_handling(self): + # See + xml = (""" + + ${select('.')} + + + + fish + fish + fish + fish + + """) + tmpl = MarkupTemplate(xml, filename='test.html') + self.assertEqual(""" + + fish + fish + fish + fish + + """, tmpl.generate().render(encoding=None)) + def suite(): suite = unittest.TestSuite()