Mercurial > genshi > mirror
changeset 369:0d749146842c stable-0.3.x
Ported [444] to 0.3.x.
author | cmlenz |
---|---|
date | Wed, 22 Nov 2006 21:00:43 +0000 |
parents | 94ff33bfe515 |
children | 077fe85dff13 |
files | genshi/path.py genshi/template.py genshi/tests/template.py |
diffstat | 3 files changed, 53 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/genshi/path.py +++ b/genshi/path.py @@ -545,7 +545,7 @@ return '%s:*' % self.prefix class LocalNameTest(object): - """Node test that matches any event with the given prinipal type and + """Node test that matches any event with the given principal type and local name. """ __slots__ = ['principal_type', 'name'] @@ -562,7 +562,7 @@ return self.name class QualifiedNameTest(object): - """Node test that matches any event with the given prinipal type and + """Node test that matches any event with the given principal type and qualified name. """ __slots__ = ['principal_type', 'prefix', 'name']
--- a/genshi/template.py +++ b/genshi/template.py @@ -1140,8 +1140,9 @@ # Consume and store all events until an end event # corresponding to this start event is encountered - content = chain([(kind, data, pos)], - self._match(_strip(stream), ctxt), + content = chain([(kind, data, pos)], + self._match(_strip(stream), ctxt, + [match_templates[idx]]), tail) for filter_ in self.filters[3:]: content = filter_(content, ctxt)
--- a/genshi/tests/template.py +++ b/genshi/tests/template.py @@ -590,6 +590,54 @@ </body> </html>""", str(tmpl.generate())) + def test_not_match_self(self): + """ + See http://genshi.edgewall.org/ticket/77 + """ + tmpl = MarkupTemplate("""<html xmlns="http://www.w3.org/1999/xhtml" + xmlns:py="http://genshi.edgewall.org/"> + <body py:match="body" py:content="select('*')" /> + <h1 py:match="h1"> + ${select('text()')} + Goodbye! + </h1> + <body> + <h1>Hello!</h1> + </body> + </html>""") + self.assertEqual("""<html xmlns="http://www.w3.org/1999/xhtml"> + <body><h1> + Hello! + Goodbye! + </h1></body> + </html>""", str(tmpl.generate())) + + def test_select_text_in_element(self): + """ + See http://genshi.edgewall.org/ticket/77#comment:1 + """ + tmpl = MarkupTemplate("""<html xmlns="http://www.w3.org/1999/xhtml" + xmlns:py="http://genshi.edgewall.org/"> + <body py:match="body" py:content="select('*')" /> + <h1 py:match="h1"> + <text> + ${select('text()')} + </text> + Goodbye! + </h1> + <body> + <h1>Hello!</h1> + </body> + </html>""") + self.assertEqual("""<html xmlns="http://www.w3.org/1999/xhtml"> + <body><h1> + <text> + Hello! + </text> + Goodbye! + </h1></body> + </html>""", str(tmpl.generate())) + def test_select_all_attrs(self): tmpl = MarkupTemplate("""<doc xmlns:py="http://genshi.edgewall.org/"> <div py:match="elem" py:attrs="select('@*')">