Hi all,
I've patched the Directory plugin to allow filename filtering.
Now you can do like so:
[% USE d = Directory(somedir,root=someroot) %]
[% d.files.size %] # maybe 100 files
[% d.files('jpe?g$').size %] # but only 90 jpeg images
This against Template 2.06. Hopefully not too heinous; it's my first
patch.
-Allen
*** Directory.pm.orig Sun Mar 10 21:30:58 2002
--- Directory.pm.new Sun Mar 10 21:30:55 2002
***************
*** 64,69 ****
--- 64,80 ----
}
+ sub files {
+ my ($self, $pattern) = @_;
+
+ my @match = ();
+ foreach my $file (@{$self->{files}}){
+ push @match, $file if $file->{ name } =~ /$pattern/;
+ }
+
+ return \@match;
+ }
+
#------------------------------------------------------------------------
# scan(\%config)
#