[Templates] Including all files in a directory
Garrett, Philip (MAN-Corporate)
Philip.Garrett@manheim.com
Fri, 28 Jul 2006 09:54:05 -0400
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.
>=20
> =
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
> [% USE dir =3D Directory('announce/') %]
> [% FOREACH file =3D dir.files %]
> FILE =3D [% file.name%]
> [% INCLUDE file %]
>=20
> [% 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}" %]
Regards,
Philip