[WM] Recursive reading of content files

Warren Post munisrc.softhome.net
Tue Dec 31 09:53:04 GMT 2002


Duncan Cameron wrote:

> 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
>>
(snip)
>>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}">

Thank you, Duncan. With this code I can now recursively read the source 
files and recursively create output files:

<contents src="../src" name=".../*.txt" listname="srcfiles" />

<content name=all_files>
<{perl
   # borrowed 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}}" }>
   ${page_template}
</content>

<for name="out" values="${srcfiles}">
   <out file="${out}.html" name="${out}">
     ${out_helper}
   </out>
</for>

...but I broke something. Now my output files are in the form 
name.txt.html. Source file name.txt was correctly producing name.html. 
Now however name.txt is producing name.txt.html. What should I be 
looking at to fix my error?

Happy new year, all.
-- 
Warren Post, Voluntario Naciones Unidas
Departamento de Informática
Municipalidad de Santa Rosa de Copán, Honduras
http://santarosahistorica.net/





More information about the Webmake-talk mailing list