Opened 18 years ago
Closed 18 years ago
#30 closed defect (fixed)
Arguments of <py:def>s are lost when function evaluated in a select('*')
Reported by: | cboos | Owned by: | cmlenz |
---|---|---|---|
Priority: | major | Milestone: | 0.2 |
Component: | Expression evaluation | Version: | 0.1 |
Keywords: | Cc: |
Description
I've seen this while converting the changeset.cs Trac template, as there I used a macro for the title, and then I noticed some garbage in the <head> element.
I reproduced the problem with the following snippet:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:py="http://markup.edgewall.org/" xmlns:xi="http://www.w3.org/2001/XInclude"> <py:def function="title_macro(test)"> <py:choose test=""> <py:when test="test">$test OK</py:when> <py:otherwise>$test WHY?</py:otherwise> </py:choose> </py:def> <head py:match="head">${select('*')}</head> <head><title>${title_macro(True)}</title></head> ---- ${title_macro(True)} ---- ++++ ${title_macro(False)} ++++ </html>
The output:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head><title> WHY? </title></head> ---- True OK ---- ++++ False WHY? ++++ </html>
The problem is that we see WHY? in <head><title>, where we should see True OK. This is because the test argument evaluates to None within select('*') (I think).
Of course, if there's no <py:match>, <head><title> has the correct True OK content.
Change History (1)
comment:1 Changed 18 years ago by cmlenz
- Resolution set to fixed
- Status changed from new to closed
Note: See
TracTickets for help on using
tickets.
Should be fixed in [216].