Mercurial > genshi > mirror
changeset 946:6492fab2229a stable-0.6.x
Merge r1170 from trunk (fix error in match template processing -- see #370 comment 12).
author | hodgestar |
---|---|
date | Tue, 30 Aug 2011 12:52:08 +0000 |
parents | 5c7d69204287 |
children | cccbcbd33e90 |
files | genshi/template/markup.py genshi/template/tests/directives.py |
diffstat | 2 files changed, 25 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- 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
--- a/genshi/template/tests/directives.py +++ b/genshi/template/tests/directives.py @@ -1005,6 +1005,27 @@ </body> </html>""", tmpl.generate().render()) + def test_match_multiple_times3(self): + # See http://genshi.edgewall.org/ticket/370#comment:12 + tmpl = MarkupTemplate("""<?xml version="1.0"?> + <root xmlns:py="http://genshi.edgewall.org/"> + <py:match path="foo/bar"> + <zzzzz/> + </py:match> + <foo> + <bar/> + <bar/> + </foo> + <bar/> + </root>""") + self.assertEqual("""<?xml version="1.0"?>\n<root> + <foo> + <zzzzz/> + <zzzzz/> + </foo> + <bar/> + </root>""", tmpl.generate().render()) + # FIXME #def test_match_after_step(self): # tmpl = MarkupTemplate("""<div xmlns:py="http://genshi.edgewall.org/">