RE: [Templates] Reverse a list?

2003-07-28 Thread Peter Guzis
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: [EMAIL PROTECTED]
www.encad.com 

-Original Message-
From: Bryce Harrington [mailto:[EMAIL PROTECTED]
Sent: Monday, July 28, 2003 1:03 PM
To: [EMAIL PROTECTED]
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
[EMAIL PROTECTED]
http://lists.template-toolkit.org/mailman/listinfo/templates

___
templates mailing list
[EMAIL PROTECTED]
http://lists.template-toolkit.org/mailman/listinfo/templates


Re: [Templates] Reverse a list?

2003-07-28 Thread Stefano Rodighiero
Bryce Harrington wrote:

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...
Looking in Template::Manual::VMethods, you'll find the reverse
method. Here an excerpt from the pod:
   reverse
   Returns the items of the list in reverse order.
   [% FOREACH s = scores.reverse %]
  ...
   [% END %]
cheers,
Stefano


___
templates mailing list
[EMAIL PROTECTED]
http://lists.template-toolkit.org/mailman/listinfo/templates


RE: [Templates] Reverse a list?

2003-07-28 Thread Bryce Harrington
Aha!  Perfect, thanks!

On Mon, 28 Jul 2003, Peter Guzis wrote:
 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: [EMAIL PROTECTED]
 www.encad.com

 -Original Message-
 From: Bryce Harrington [mailto:[EMAIL PROTECTED]
 Sent: Monday, July 28, 2003 1:03 PM
 To: [EMAIL PROTECTED]
 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
 [EMAIL PROTECTED]
 http://lists.template-toolkit.org/mailman/listinfo/templates

 ___
 templates mailing list
 [EMAIL PROTECTED]
 http://lists.template-toolkit.org/mailman/listinfo/templates



___
templates mailing list
[EMAIL PROTECTED]
http://lists.template-toolkit.org/mailman/listinfo/templates