试图根据条件更改表数据。
<td tal:condition="string.stringname != '-shadow'"><strong>Stuff</strong></td>
<td tal:condition="string.stringname == '-shadow'"><em>Stuff</em></td>string.stringname可能在字符串的末尾有-shadow,但它可能没有。我试图让tal根据其中一个或另一个是否为真来显示任何一个表数据。如果这两种情况都满足,页面将需要显示这两种情况。tal:condition似乎无法搜索字符串是否包含某些内容,只有当某些内容显式为真或假时才能搜索。
发布于 2014-04-01 18:35:34
使用str.endswith()测试一个字符串是否以给定的子字符串结尾:
<td tal:condition="not string.stringname.endswith('-shadow')"><strong>Stuff</strong></td>
<td tal:condition="string.stringname.endswith('-shadow')"><em>Stuff</em></td>https://stackoverflow.com/questions/22794071
复制相似问题