Hi,

Occasionally I want -- during template processing -- to access files
that are in the directory where the template resides. For example, to
create an HTML page that shows all images in this directory.

Template::Plugin::Directory is a good start, but unfortunately it has
a different view on the file system than would be intuitive. For
example, to show all images in the current directory:

  USE dir = Directory(dirpath);
  FOREACH file = dir.files;
    '<img src="' _ file.name _ '">";
  END;

The problem is how to get the right value for dirpath. An intuitive
approach would be to use ".", as this usually means the 'current
directory', but unfortunately this results in the current directory
where the ttree command is executed. 

Yes, it is possible to construct the 'real' current directory using
the template source directory and the path name of the current
template, but this is cumbersome.

Is there a better way to access files relative to the location of the
template?

-- Johan

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

Reply via email to