[ZPT] reversing a repeat
Richard Jones
richard@bizarsoftware.com.au
Sat, 23 Jun 2001 10:44:45 +1000
On Sat, 23 Jun 2001 10:23, Phil Harris wrote:
> Hi all,
>
> I have this bit of code:
>
> <div metal:fill-slot="main" id="main">
> <span tal:repeat="item here/Catalog">
> <div class="articleTitle">
> <a class="articleLink" href="" tal:attributes="href item/linkUrl"
> tal:content="item/Title">link text</a>
> <div class="email">
> <span tal:replace="here/bobobase_modification_time">timedate
> here</span>
> (<a href="mailto:" tal:attributes="href python:'mailto' +
> item.email" tal:content="item/author">author</a>)
> </div>
> </div>
> <div class="article" tal:content="item/content"> </div>
> <br />
> </span>
> </div>
>
>
> Which works fine, but I would like to reverse the results from the call to
> Catalog.
>
> I can't see any way, out of the box, that 'repeat' can reverse the results.
Try something like:
<span tal:define="res python:['1','2','3','4']"
tal:repeat="r python:res.reverse() or res"
tal:content="r">hello, world</span>
Richard
--
Richard Jones
richard@bizarsoftware.com.au
Senior Software Developer, Bizar Software (www.bizarsoftware.com.au)