On Wed, Dec 15, 2004 at 02:15:34AM +0100, Jaroslav Lukesh wrote:
Dne pond?l?, 13. prosince 2004 17:45 Florent Guillaume napsal(a):
Well there's always a way to hack it in using structure, like in:
<table> <tr> <tal:block repeat="item mydatalist"> <td tal:content="item/title_or_id">Title</td> <div tal:condition="python:repeat['item'].index % 4 == 3" tal:replace="structure string:</tr><tr>" /> </tal:block> </tr> </table>
nice piece, but it broke main idea of ZPT - separation design from logic. BFU designer could easily broke that code.
Yeah it smells too funny to me. I'd rather wrap it up in a trivial and reusable script: ##parameters=data,batchsize """ Break up list *data* into sub-lists of size *batchsize*. """ indeces = range(0, len(data), batchsize) result = [data[i:i+batchsize] for i in indeces] return result This makes the template relatively clean and concise: <table> <tr tal:repeat="row python:myscript(mydatalist, 4)"> <td tal:repeat="item row" tal:content="item/title_or_id">Title</td> </tr> </table> -- Paul Winkler http://www.slinkp.com