我一直在尝试获取genshi py:if来处理python表达式。为了简单起见,我尝试了下面的代码。
<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">任何人都知道我如何使这个if语句与python表达式一起工作。谢谢
发布于 2013-03-13 23:06:41
您不需要在模板指令中使用大括号。
尝尝这个
<py:if test="len(linstoflinks)>0">https://stackoverflow.com/questions/14790879
复制相似问题