# HG changeset patch # User hodgestar # Date 1299746465 0 # Node ID a1f3bbe1a680ccbbf4b01f1a208e10db9937c042 # Parent 5dcabf565db1337f467d7d6e05561b05701b2099 Merge r1149 from trunk (fix for tail selecting issue #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()