#77 closed defect (fixed)
Match templates can match their own output
Reported by: | dackze+genshi@… | Owned by: | cmlenz |
---|---|---|---|
Priority: | major | Milestone: | 0.3.5 |
Component: | Template processing | Version: | devel |
Keywords: | Cc: |
Description
This is really hurting my head and I'm not exactly sure how to explain this, so here are some examples:
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:py="http://genshi.edgewall.org/"> <body py:match="body" py:content="select('*')" /> <h1 py:match="h1"> ${select('text()')} Goodbye! </h1> <body> <h1>Hello!</h1> </body> </html>
Produces:
<html xmlns="http://www.w3.org/1999/xhtml"> <body><h1> Hello! Goodbye! Goodbye! </h1></body> </html>
It seems to be triggered by the first match template outputting what the second match template matches, and by the name of the second match template matching its own query. If you make the first match template not output the <h1>Hello</h1> element, or change the <h1 py:match="h1"> element to not match its own query, the problem disappears.
I'm not sure if this is intentional, but for what it's worth, Kid doesn't seem to behave this way:
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:py="http://purl.org/kid/ns#"> <body py:match="item.tag == '{http://www.w3.org/1999/xhtml}body'" py:content="[item.text] + item[:]" /> <h1 py:match="item.tag == '{http://www.w3.org/1999/xhtml}h1'"> ${item.text} Goodbye! </h1> <body> <h1>Hello!</h1> </body> </html>
Produces:
<?xml version="1.0" encoding="utf-8"?> <html xmlns="http://www.w3.org/1999/xhtml"> <body> <h1> Hello! Goodbye! </h1> </body>
The examples are contrived, but I originally ran into this with a form template that filled in fields via match templates. I had a match template that put error messages beneath fields with invalid input, and when I threw a match-based layout template into the mix, I started getting two of each error list.
Also, this seems to happen in all of the current branches, the current trunk, and all of the 0.3 tags.
Attachments (1)
Change History (5)
comment:1 Changed 18 years ago by dackze+genshi@…
comment:2 Changed 18 years ago by cmlenz
- Resolution set to fixed
- Status changed from new to closed
Fix checked in in [444].
Thanks a lot for those test cases, very helpful!
comment:3 Changed 18 years ago by cmlenz
- Milestone changed from 0.4 to 0.3.5
- Resolution fixed deleted
- Status changed from closed to reopened
Should be ported 0.3.x.
comment:4 Changed 18 years ago by cmlenz
- Resolution set to fixed
- Status changed from reopened to closed
Ported to 0.3.x in [449].
Here's another weird side effect of this behavior:
Produces:
The "Hello!" wasn't selected. If you remove the first match template, it is selected:
Produces: