Newbie question: include all files
"Kiss Gabor (Bitman)" <kissg-8/[email protected]> Tue, 4 Jun 2013 16:37:18 +0200 (CEST)
| Newsgroups | gmane.comp.lang.perl.modules.template-toolkit |
|---|---|
| Message-ID | <[email protected]> |
Dear folks,
After one and half document reading and web search I can't figure
out how to include all files from a directory relative to the
main template.
Directory structure is like
/usr/local/lib/templates/foo/version1/-+-main.tt
|
+-features/-+-bar
|
+-baz
Template processor is called with INCLUDE_PATH="/usr/local/lib/templates",
and the template to process is called as "foo/version1/main.tt".
I should find a way to include all files under features
directory but their number and name is not known in advance.
With hardcoded absolute paths in main.tt I could do it:
[% USE dir = Directory('/usr/local/lib/templates/foo/version1/features') %]
[% FOREACH file = dir.files %]
[% PROCESS "/usr/local/lib/templates/foo/version1/features/$file.name" %]
[% END %]
But this is not acceptable. Include path most relative to the directory
containing main.tt not depending on its absolute location.
Any hint will be appreciated. (As well as strictly checked. :)
Gabor