[Templates] Including all files in a directory
Dave Howorth
dhoworth@mrc-lmb.cam.ac.uk
Fri, 28 Jul 2006 15:31:43 +0100
Garrett, Philip (MAN-Corporate) wrote:
> andrew3@black1.org.uk wrote:
>>Hi
>>I am trying to read every file in a directory. The code below is my
>>attempt but it give file not found.
>>
>>===============================================
>>[% USE dir = Directory('announce/') %]
>> [% FOREACH file = dir.files %]
>> FILE = [% file.name%]
>> [% INCLUDE file %]
>>
>> [% END %]
>
> It's interpreting file.name as a literal filename, i.e. it would appear
> in your directory as "file.name".
>
> This works by forcing TT2 to interpolate the variable:
> [% INCLUDE "${file.name}" %]
Errm, I think that should be:
[% INCLUDE "announce/${file.name}" %]
Cheers, Dave