Edgewall Software

Ticket #254: genshi-254.patch

File genshi-254.patch, 2.0 KB (added by Felix Schwarz <felix.schwarz@…>, 14 years ago)

finally a patch for the dreaded issue

  • genshi/template/markup.py

    diff -r 36ec0c51e5e5 genshi/template/markup.py
    a b  
    358358                        pre_end -= 1
    359359                    inner = _strip(stream)
    360360                    if pre_end > 0:
    361                         inner = self._match(inner, ctxt, end=pre_end, **vars)
     361                        inner = self._match(inner, ctxt, start=start, end=pre_end, **vars)
    362362                    content = self._include(chain([event], inner, tail), ctxt)
    363363                    if 'not_buffered' not in hints:
    364364                        content = list(content)
  • genshi/template/tests/directives.py

    diff -r 36ec0c51e5e5 genshi/template/tests/directives.py
    a b  
    961961    #        Hello Dude
    962962    #      </span>
    963963    #    </div>""", tmpl.generate().render(encoding=None))
     964   
     965    def test_triple_match_produces_no_duplicate_items(self):
     966        tmpl = MarkupTemplate("""<doc xmlns="http://www.w3.org/1999/xhtml" xmlns:py="http://genshi.edgewall.org/">
     967              <div py:match="div[@id='content']" py:attrs="select('@*')" once="true">
     968                <ul id="tabbed_pane" />
     969                ${select('*')}
     970              </div>
     971
     972              <body py:match="body" once="true" buffer="false">
     973                ${select('*|text()')}
     974              </body>
     975              <body py:match="body" once="true" buffer="false">
     976                  ${select('*|text()')}
     977              </body>
     978
     979              <body>
     980                <div id="content">
     981                  <h1>Ticket X</h1>
     982                </div>
     983              </body>
     984            </doc>""")
     985        output = tmpl.generate().render('xhtml', doctype='xhtml')
     986        matches = re.findall("tabbed_pane", output)
     987        self.assertNotEqual(None, matches)
     988        self.assertEqual(1, len(matches))
    964989
    965990
    966991class ContentDirectiveTestCase(unittest.TestCase):