# HG changeset patch # User hodgestar # Date 1314708537 0 # Node ID d1edb246cc6186fa8a8a615c6c82432353ea59a5 # Parent 657f9ecffa3cd9bed14997584de54c7c3351a62b Fix out-by-one error introduced in r1097 that led to match templates missing the last event from the stream they were processing. diff --git a/genshi/template/markup.py b/genshi/template/markup.py --- a/genshi/template/markup.py +++ b/genshi/template/markup.py @@ -385,10 +385,11 @@ for event in content: pass - # Let the remaining match templates know about the last - # event in the matched content, so they can update their + # Let this match template and the remaining match + # templates know about the last event in the + # matched content, so they can update their # internal state accordingly - for test in [mt[0] for mt in match_templates[idx + 1:]]: + for test in [mt[0] for mt in match_templates[idx:]]: test(tail[0], namespaces, ctxt, updateonly=True) break diff --git a/genshi/template/tests/directives.py b/genshi/template/tests/directives.py --- a/genshi/template/tests/directives.py +++ b/genshi/template/tests/directives.py @@ -1005,6 +1005,27 @@ """, tmpl.generate().render()) + def test_match_multiple_times3(self): + # See http://genshi.edgewall.org/ticket/370#comment:12 + tmpl = MarkupTemplate(""" + + + + + + + + + + """) + self.assertEqual("""\n + + + + + + """, tmpl.generate().render()) + # FIXME #def test_match_after_step(self): # tmpl = MarkupTemplate("""