Genshi: if / else

How to make simple if / else in Genshi template language?

I found this ticket , which seems to suggest that Genshi does not support if / else, but this does not really explain what it supports.

I just want something like this:

<py:if test="c.row.currency"> ${c.row.currency.upper()} <py:else> ${c.row.dataset_.currency.upper()} </py:if> 

But I get "Bad Directive: else". Should I use py: select instead ? I cannot figure out how to use it for the if / else condition.

+6
python genshi pylons
source share
1 answer

Currently, you cannot if else is being built in Genshi, and as far as I know, it is not planned to be added. Instead, as you mentioned, use py: select. The following describes how you use py: select a type of type if / else:

 <py:choose ...> <py:when test="..."> ${c.row.currency.upper()} </py:when> <py:otherwise> ${c.row.currency.upper()} </py:otherwise> </py:choose> 
+8
source share

All Articles