Ticket #186: ticket186.diff
| File ticket186.diff, 2.9 KB (added by cmlenz, 5 years ago) |
|---|
-
genshi/template/tests/directives.py
631 631 </body> 632 632 </html>""", str(tmpl.generate())) 633 633 634 def test_recursive_match_3(self): 635 tmpl = MarkupTemplate("""<test xmlns:py="http://genshi.edgewall.org/"> 636 <py:match path="b[@type='bullet']"> 637 <bullet>${select('*|text()')}</bullet> 638 </py:match> 639 <py:match path="group[@type='bullet']"> 640 <ul>${select('*')}</ul> 641 </py:match> 642 <py:match path="b"> 643 <generic>${select('*|text()')}</generic> 644 </py:match> 645 646 <b> 647 <group type="bullet"> 648 <b type="bullet">1</b> 649 <b type="bullet">2</b> 650 </group> 651 </b> 652 </test> 653 """) 654 self.assertEqual("""<test> 655 <generic> 656 <ul><bullet>1</bullet><bullet>2</bullet></ul> 657 </generic> 658 </test>""", str(tmpl.generate())) 659 634 660 def test_not_match_self(self): 635 661 """ 636 662 See http://genshi.edgewall.org/ticket/77 -
genshi/template/markup.py
272 272 # Consume and store all events until an end event 273 273 # corresponding to this start event is encountered 274 274 inner = _strip(stream) 275 if 'match_once' not in hints \ 276 and 'not_recursive' not in hints: 277 inner = self._match(inner, ctxt, [match_templates[idx]]) 275 pre_match_templates = match_templates[:idx + 1] 276 if 'match_once' not in hints and 'not_recursive' in hints: 277 pre_match_templates.pop() 278 inner = self._match(inner, ctxt, pre_match_templates) 278 279 content = list(self._include(chain([event], inner, tail), 279 280 ctxt)) 280 281 … … 290 291 # Recursively process the output 291 292 template = _apply_directives(template, ctxt, directives) 292 293 remaining = match_templates 293 if 'match_once' not in hints:294 remaining = remaining[:idx] + remaining[idx + 1:]295 294 for event in self._match(self._exec( 296 295 self._eval(self._flatten(template, ctxt), 297 ctxt), ctxt), ctxt, remaining):296 ctxt), ctxt), ctxt, match_templates[idx + 1:]): 298 297 yield event 299 298 300 299 ctxt.pop()
