Edgewall Software

Opened 16 years ago

Closed 16 years ago

#244 closed defect (duplicate)

Second py:match does not replace contents of first py:match in Genshi 0.5

Reported by: felix.schwarz@… Owned by: cmlenz
Priority: major Milestone:
Component: Template processing Version: 0.5
Keywords: Cc:

Description

Since I switched from Genshi 0.4.4 to Genshi 0.5 some of my templates don't work anymore. This is because I xi:include a template which uses py:match. After that I want to change the result of the first application of py:match in a second py:match from my template.

But the second py:match never matches. This worked with Genshi 0.4.4.

Attachments (1)

test_no_match.py (2.3 KB) - added by felix.schwarz@… 16 years ago.

Download all attachments as: .zip

Change History (5)

Changed 16 years ago by felix.schwarz@…

comment:1 Changed 16 years ago by felix.schwarz@…

I should add that it works if the py:match xpath in foo.html is 'body' and not an element inside the output which was generated by py:match.

comment:2 Changed 16 years ago by cmlenz

  • Component changed from General to Template processing

This is an effect of a change made to the way match templates are processed. As noted in the upgrade document:

There has also been a subtle change to how py:match templates are processed: in previous versions, all match templates would be applied to the content generated by the matching template, and only the matching template itself was applied recursively to the original content. This behavior resulted in problems with many kinds of recursive matching, and hence was changed for 0.5: now, all match templates declared before the matching template are applied to the original content, and match templates declared after the matching template are applied to the generated content. This change should not have any effect on most applications, but you may want to check your use of match templates to make sure.

See also r810 and #186.

You want your div[@id='banner'] to be applied to the output of the body match template, but the format match template is defined before the latter, and will not see the output generated by the body match template.

So in this particular case, you'd need to move the div[@id='banner'] match template between the body match template and the <body> itself.

I understand that this change was more disruptive than I had initially thought and that the pattern you're using here is not supported. However, the previous behavior of applying match templates to both the input and the output of every other match template was causing other issues (as described in #186), and was rather messy in implementation.

Not sure what to do about this right now.

comment:3 Changed 16 years ago by cmlenz

  • Milestone changed from 0.5.1 to 0.5.2

comment:4 Changed 16 years ago by cmlenz

  • Milestone 0.5.2 deleted
  • Resolution set to duplicate
  • Status changed from new to closed

This turned out to be a duplicate of #217.

Note: See TracTickets for help on using tickets.