[WM] Recursive reading of content files
Duncan Cameron
dcameron.bcs.org.uk
Tue Dec 31 01:58:03 GMT 2002
On 2002-12-30 Warren Post wrote:
>I have content files, one per output page, in a directory structure that
>mimics the directory structure of my site, like:
>
>/
> root1.txt
> root2.txt
> /albert/
> albert1.txt
> albert2.txt
> /bill/
> bill1.txt
> bill2.txt
> /abigail/
> abigail1.txt
> abigail2.txt
>
>....and so on. I want WebMake to read each file and create the
>corresponding output files. From one of jmason's examples I have the
>following in my .wmk file:
>
><contents src="." name=".../*.txt" />
><content name=all_files>
><{perl
> # this script from webmake.taint.org
> # create a ${all_files} variable containing the list
> # of all the text files we just loaded.
> $_ = "";
> foreach my $pg (content_matching ("*.txt")) {
> $pg =~ s/.txt//; $_ .= "$pg ";
> }
> $_;
>}>
></content>
>
><content name=out_helper>
> <{set page_text="${${WebMake.OutName}.txt}" }>
> ${page_template}
></content>
>
><for name="out" values="${all_files}">
> <out file="${out}.html" name="${out}">
> ${out_helper}
> </out>
></for>
>
>....which reads and processes all content files in the root directory
>(root1 and root2 in the example above) but does not recursively read the
>files in subdirectories. What am I missing to recursively read the files
>in the subdirectories?
>
Just use the listname attribute on the contents tag, which you can
then use in a for tag:
<contents src="raw" name=".../*.htm" skip="menu.htm"
listname="htmfiles"/>
<for name="page" values="${htmfiles}">
Not sure what is wrong with your example though.
There is a subroutine glob_to_re() in Util.pm that tries to convert
the '*.txt' into a regular expression and it doesn't seem to give
what you want. Maybe there's a bug in there?
Regards,
Duncan Cameron
More information about the Webmake-talk
mailing list