Mercurial > genshi > mirror
changeset 211:e5151983df0d trunk
Fix another regression introduced in [258]: some kinds of cascaded match templates were broken, for example in the TurboGears example app.
author | cmlenz |
---|---|
date | Tue, 29 Aug 2006 21:14:58 +0000 |
parents | 9fd7535883f2 |
children | 0141f45c18e1 |
files | markup/path.py markup/tests/template.py |
diffstat | 2 files changed, 20 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/markup/path.py +++ b/markup/path.py @@ -151,16 +151,17 @@ def _test(kind, data, pos, variables): for steps, size, stack in paths: + if kind is END: + if stack: + stack.pop() + continue + elif kind is START: + stack.append(stack and stack[-1] or 0) + if not stack: continue cursor = stack[-1] - if kind is END: - stack.pop() - continue - elif kind is START: - stack.append(cursor) - while 1: axis, nodetest, predicates = steps[cursor]
--- a/markup/tests/template.py +++ b/markup/tests/template.py @@ -588,6 +588,19 @@ <div>I said <q>bar</q>.</div> </html>""", str(tmpl.generate())) + def test_cascaded_matches(self): + tmpl = Template("""<html xmlns:py="http://markup.edgewall.org/"> + <body py:match="body">${select('*')}</body> + <head py:match="head">${select('title')}</head> + <body py:match="body">${select('*')}<hr /></body> + <head><title>Welcome to Markup</title></head> + <body><h2>Are you ready to mark up?</h2></body> + </html>""") + self.assertEqual("""<html> + <head><title>Welcome to Markup</title></head> + <body><h2>Are you ready to mark up?</h2><hr/></body> + </html>""", str(tmpl.generate())) + # FIXME #def test_match_after_step(self): # tmpl = Template("""<div xmlns:py="http://markup.edgewall.org/">