Edgewall Software

Changeset 1097


Ignore:
Timestamp:
Apr 15, 2010, 10:30:09 PM (13 years ago)
Author:
cmlenz
Message:

Fix for match template processing involving multiple match directives targetting the same element. Should close #370.

Location:
trunk/genshi/template
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/genshi/template/markup.py

    r1093 r1097  
    392392                    # event in the matched content, so they can update their
    393393                    # internal state accordingly
    394                     for test in [mt[0] for mt in match_templates]:
     394                    for test in [mt[0] for mt in match_templates[idx + 1:]]:
    395395                        test(tail[0], namespaces, ctxt, updateonly=True)
    396396
  • trunk/genshi/template/tests/directives.py

    r1093 r1097  
    975975        self.assertEqual(1, len(matches))
    976976
     977    def test_match_multiple_times1(self):
     978        # See http://genshi.edgewall.org/ticket/370
     979        tmpl = MarkupTemplate("""<html xmlns:py="http://genshi.edgewall.org/">
     980          <py:match path="body[@id='content']/h2" />
     981          <head py:match="head" />
     982          <head py:match="head" />
     983          <head />
     984          <body />
     985        </html>""")
     986        self.assertEqual("""<html>
     987          <head/>
     988          <body/>
     989        </html>""", tmpl.generate().render())
     990
     991    def test_match_multiple_times2(self):
     992        # See http://genshi.edgewall.org/ticket/370
     993        tmpl = MarkupTemplate("""<html xmlns:py="http://genshi.edgewall.org/">
     994          <py:match path="body/div[@id='properties']" />
     995          <head py:match="head" />
     996          <head py:match="head" />
     997          <head/>
     998          <body>
     999            <div id="properties">Foo</div>
     1000          </body>
     1001        </html>""")
     1002        self.assertEqual("""<html>
     1003          <head/>
     1004          <body>
     1005          </body>
     1006        </html>""", tmpl.generate().render())
     1007
    9771008    # FIXME
    9781009    #def test_match_after_step(self):
Note: See TracChangeset for help on using the changeset viewer.