Mercurial > genshi > mirror
changeset 874:49614704bbc7 trunk
Fix for match template processing involving multiple match directives targetting the same element. Should close #370.
author | cmlenz |
---|---|
date | Thu, 15 Apr 2010 20:30:09 +0000 |
parents | 4e8100e83bdd |
children | 5c7454462cd3 |
files | genshi/template/markup.py genshi/template/tests/directives.py |
diffstat | 2 files changed, 32 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- 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
--- 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("""<html xmlns:py="http://genshi.edgewall.org/"> + <py:match path="body[@id='content']/h2" /> + <head py:match="head" /> + <head py:match="head" /> + <head /> + <body /> + </html>""") + self.assertEqual("""<html> + <head/> + <body/> + </html>""", tmpl.generate().render()) + + def test_match_multiple_times2(self): + # See http://genshi.edgewall.org/ticket/370 + tmpl = MarkupTemplate("""<html xmlns:py="http://genshi.edgewall.org/"> + <py:match path="body/div[@id='properties']" /> + <head py:match="head" /> + <head py:match="head" /> + <head/> + <body> + <div id="properties">Foo</div> + </body> + </html>""") + self.assertEqual("""<html> + <head/> + <body> + </body> + </html>""", tmpl.generate().render()) + # FIXME #def test_match_after_step(self): # tmpl = MarkupTemplate("""<div xmlns:py="http://genshi.edgewall.org/">