Mercurial > genshi > mirror
changeset 870:c52e2bf11edc trunk
Apply patch Felix Schwarz that finally fixes the duplicated output in match template processing. Thanks so much!
author | cmlenz |
---|---|
date | Thu, 18 Feb 2010 09:17:45 +0000 |
parents | 013623773357 |
children | b6deffd8ecce |
files | ChangeLog genshi/template/markup.py genshi/template/tests/directives.py |
diffstat | 3 files changed, 31 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog +++ b/ChangeLog @@ -13,12 +13,6 @@ by Marcin Kurczych during GSoC 2008. * Added caching in the serialization stage for improved performance. * Various improvements to the HTML sanitization filter. - - -Version 0.5.2 -http://svn.edgewall.org/repos/genshi/tags/0.5.2/ -(???, from branches/stable/0.5.x) - * Fix problem with I18n filter that would get confused by expressions in attribute values when inside an `i18n:msg` block (ticket #250). * Fix problem with the transformation filter dropping events after the @@ -32,6 +26,8 @@ * Fixed handling of relative URLs with fragment identifiers containing colons in the `HTMLSanitizer` (ticket #274). * Added an option to the `HTMLFiller` to also populate password fields. + * Match template processing no longer produces unwanted duplicate output in + some cases (ticket #254). Version 0.5.1
--- a/genshi/template/markup.py +++ b/genshi/template/markup.py @@ -358,7 +358,8 @@ pre_end -= 1 inner = _strip(stream) if pre_end > 0: - inner = self._match(inner, ctxt, end=pre_end, **vars) + inner = self._match(inner, ctxt, start=start, + end=pre_end, **vars) content = self._include(chain([event], inner, tail), ctxt) if 'not_buffered' not in hints: content = list(content)
--- a/genshi/template/tests/directives.py +++ b/genshi/template/tests/directives.py @@ -12,6 +12,7 @@ # history and logs, available at http://genshi.edgewall.org/log/. import doctest +import re import sys import unittest @@ -947,6 +948,32 @@ </elem> </doc>""", tmpl.generate().render(encoding=None)) + # See http://genshi.edgewall.org/ticket/254/ + def test_triple_match_produces_no_duplicate_items(self): + tmpl = MarkupTemplate("""<doc xmlns:py="http://genshi.edgewall.org/"> + <div py:match="div[@id='content']" py:attrs="select('@*')" once="true"> + <ul id="tabbed_pane" /> + ${select('*')} + </div> + + <body py:match="body" once="true" buffer="false"> + ${select('*|text()')} + </body> + <body py:match="body" once="true" buffer="false"> + ${select('*|text()')} + </body> + + <body> + <div id="content"> + <h1>Ticket X</h1> + </div> + </body> + </doc>""") + output = tmpl.generate().render('xhtml', doctype='xhtml') + matches = re.findall("tabbed_pane", output) + self.assertNotEqual(None, matches) + self.assertEqual(1, len(matches)) + # FIXME #def test_match_after_step(self): # tmpl = MarkupTemplate("""<div xmlns:py="http://genshi.edgewall.org/">