<tal:block tal:repeat="image project/images">
<div
tal:define="onlyone python:if repeat.image.length==1: return 'onlyone'"
tal:attributes="class python:'image-{}'.format(repeat.image.number)">
<img
tal:define="img image/getObject"
tal:replace="structure img/@@images/image/custom_1280"
/>
</div>
</tal:block>
我已经有一个基于循环索引打印“image-N”的类,但是如果长度为“1”,我该如何添加另一个类?文档不清楚https://zope.readthedocs.io/en/latest/zopebook/AppendixC.html#tales-python-expressions,它说可以使用任何有效的python表达式,但语法对我来说总是错误的。