I would like to retrive the content of files in a directory, which fulfill a given regexp rule or string (e.g. ./*.xml).
I found following example
[% FOREACH directory.files.grep('\.txt$') %]
...
[% END %]
but do not know how to use it. Could this solve my problem?
A quick look at the documentation suggests that the output of
directory.files
is a collection of objects, so.grep()
is unlikely to work. It has methods likename
,isdir
and so on.The simplest solution would be something like:
Edit: improved answer based on suggestion by ThisSuitIsBlackNot.