# HG changeset patch # User cmlenz # Date 1271363409 0 # Node ID fcf3788122382619f2451cd3fe1a6c8aeb9df955 # Parent 9786aa2632170223548c8c7fab8892489e41ab52 Fix for match template processing involving multiple match directives targetting the same element. Should close #370. diff --git a/genshi/template/markup.py b/genshi/template/markup.py --- a/genshi/template/markup.py +++ b/genshi/template/markup.py @@ -391,7 +391,7 @@ # Let 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]: + for test in [mt[0] for mt in match_templates[idx + 1:]]: 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 @@ -974,6 +974,37 @@ self.assertNotEqual(None, matches) self.assertEqual(1, len(matches)) + def test_match_multiple_times1(self): + # See http://genshi.edgewall.org/ticket/370 + tmpl = MarkupTemplate(""" + + + + + + """) + self.assertEqual(""" + + + """, tmpl.generate().render()) + + def test_match_multiple_times2(self): + # See http://genshi.edgewall.org/ticket/370 + tmpl = MarkupTemplate(""" + + + + + +
Foo
+ + """) + self.assertEqual(""" + + + + """, tmpl.generate().render()) + # FIXME #def test_match_after_step(self): # tmpl = MarkupTemplate("""