Edgewall Software

Ticket #244 (closed defect: duplicate)

Opened 4 years ago

Last modified 4 years ago

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

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

Change History

Changed 4 years ago by felix.schwarz@…

Changed 4 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.

Changed 4 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.

Changed 4 years ago by cmlenz

  • milestone changed from 0.5.1 to 0.5.2

Changed 4 years ago by cmlenz

  • status changed from new to closed
  • resolution set to duplicate
  • milestone 0.5.2 deleted

This turned out to be a duplicate of #217.

Add/Change #244 (Second py:match does not replace contents of first py:match in Genshi 0.5)

Author


E-mail address and user name can be saved in the Preferences.


Change Properties
<Author field>
Action
as closed
The resolution will be deleted. Next status will be 'reopened'
 
Note: See TracTickets for help on using tickets.