Garrett, Philip (MAN-Corporate) wrote:
[EMAIL PROTECTED] 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

_______________________________________________
templates mailing list
[email protected]
http://lists.template-toolkit.org/mailman/listinfo/templates

Reply via email to