logo       
Google Custom Search
    AddThis Social Bookmark Button
-->

RE: Reverse a list?: msg#00073

Subject: RE: Reverse a list?
Use the reverse virtual method.

[%- USE dir = Directory("$ttree_absdir/homepage") -%]
[%- FOREACH file = dir.files.reverse %]
    [%- INCLUDE file.name %]
[%- END %]

Peter Guzis
Web Administrator, Sr.
ENCAD, Inc.
- A Kodak Company
email: pguzis-6wkqxLQJRsEAvxtiuMwx3w@xxxxxxxxxxxxxxxx
www.encad.com 

-----Original Message-----
From: Bryce Harrington [mailto:bryce-3NddpPZAyC0@xxxxxxxxxxxxxxxx]
Sent: Monday, July 28, 2003 1:03 PM
To: templates-MnLy+PD7ppGDO3lXZvfOKmD2FQJk+8+b@xxxxxxxxxxxxxxxx
Subject: [Templates] Reverse a list?


Is there a way to reverse the order of a foreach loop?
I did not see mention of it on the Template::Iterator manpage or
elsewhere...

Basically what I'm trying to do is iterate through a directory's
contents in reverse order.  I.e., something like:

[%- USE dir = Directory("$ttree_absdir/homepage") -%]
[%- FOREACH file = reverse(dir.files) %]
    [%- INCLUDE file.name %]
[%- END %]

Thanks,
Bryce


_______________________________________________
templates mailing list
templates-MnLy+PD7ppGDO3lXZvfOKmD2FQJk+8+b@xxxxxxxxxxxxxxxx
http://lists.template-toolkit.org/mailman/listinfo/templates


<Prev in Thread] Current Thread [Next in Thread>