2013-02-09 64 views
0

我一直試圖獲得genshi py:如果使用python表達式。 爲了讓事情變得簡單,我嘗試下面的代碼。Genshi if else聲明

<html xmlns="http://www.w3.org/1999/xhtml" 
    xmlns:py="http://genshi.edgewall.org/"> 
    <body> 
    <py:if test = ${len(linstoflinks)>0}> 
     <p>List has lenght</p> 
    </py:if> 
    </body> 
</html> 

在元史文檔,他們說我可以把任何Python表達式 只要我把我的表達在大括號在前面一個美元符號。 http://genshi.edgewall.org/wiki/GenshiTutorial。 我甚至嘗試

<py:if test = "${True}"> 
<py:if test = "${1==1}"> 

這個簡單的代碼不起作用。錯誤是:不能很好地形成(標記無效) 這工作

<py:if test = "foo"> 

任何人有任何想法,我怎麼能做出與Python表達式中的if語句的工作。 謝謝

+0

任何點Wiki或womething ??? – user2057547 2013-02-14 21:40:48

回答

0

你不需要模板指令中的花括號。

試試這個

<py:if test="len(linstoflinks)>0">