源氏:如果/否则
如何在 Genshi 模板语言中执行简单的 if/else?
我发现这张票,这似乎表明Genshi不支持if/else,但它并没有真正解释它支持什么。
我基本上只是想要这样的东西:
<py:if test="c.row.currency">
${c.row.currency.upper()}
<py:else>
${c.row.dataset_.currency.upper()}
</py:if>
但我得到“错误指令:其他”。我应该使用 py:choose 吗?我真的不知道如何将它用于 if/else 条件。
How do I do a simple if/else in the Genshi templating language?
I've found this ticket, which seems to suggest that Genshi doesn't support if/else, but it doesn't really explain what it supports instead.
I basically 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 be using py:choose instead? I can't really get my head around how to use it for an if/else condition.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
目前,你不能在 Genshi 中使用 if do else 构造,并且据我所知,没有计划添加它。相反,就像您提到的那样,使用 py:choose。以下是如何使用 py:choose 作为 if/else 构造的类型:
Currently, you can not if do else constructs in Genshi, and as far as I'm aware, there are no plans to add it. Instead, like you mentioned, use py:choose. The following is how you use py:choose as a type of if/else construct: