[WM] How to automatically generate html files from all wmks in a dir

Darren Cole virr at virr.net
Thu Feb 9 20:39:15 GMT 2006


jlm17 at lucent.com,

The closest I have is setting a value is in a <for> loop to be used  
in a template called from the loop (i.e. <content  
name=standard_template></content>).  I don't think this is what you  
are asking for, but maybe it will help.  At the end of the message  
I'll include the whole <for> to provide more context.

             <{set page_text="${${WebMake.OutName}.txt}" }>

I then can access page_text in my template by the normal $ 
{page_text}.  The WebMake.OutName is just accessing webmake variables  
from within the for loop so that I can get the whole file name and  
put the file in ${page_text}.  You should be able to "set_content  
($name, $value);" in your perl code to set the value of $name (say  
the string "example_text") to $value.  You could then use $ 
{example_tex}t to get at the $value.  I don't currently use this, but  
I think I at least tried it at some point (documentation for  
set_content is of course at <http://webmake.taint.org/doc/ 
PerlCodeLibrary.pm.html>).

I think you might also get the same effect by make a <for> loop  
interate over your .wmk files.  Just make a '<contents>  
src="file:wembmake_files/" format="text/wmk" name=".../.wmk"  
listname="wmk_files"/>' before your <for> loop.  I'm not sure what  
the format= attribute should be, you'd have to look that up or  
experiment.  Then define wemake_template and do whatever you want.  I  
have done something like this for a navigation bar that highlights  
which page you are currently on.  If you think this would help let me  
know, and I'll provide an example from my webmake file (though it  
doesn't do the webmake files, just text files).

Here is the full loop from my webmake file and the <contents> tag  
that sets no_nav_files list for the for loop.  ${standard_template}  
is just a template I defined using the <contents> tag.  It uses $ 
{page_text} to get the text of the whole page, so that is why I to  
the <{set ...}> stuff.

<contents src="file:no_nav/" format="text/et" name=".../*.txt"  
listname="no_nav_files" />
<!-- output for no_nav_files -->
<for name="page" namesubst="s/.txt//" values="${no_nav_files}">
	<out name="${page}" file="${page}.html">
		<{set page_text="${${WebMake.OutName}.txt}" }>
		${standard_template}
	</out>
</for>

Hope this all helps.

Darren

On Feb 2, 2006, at 4:46 , jlm17 at lucent.com wrote:

> I am trying to have webmake automatically generate html files from  
> a dynamic list of .wmk files. I have a <for> loop, but I don't know  
> how to programatically set the values= attribute. I have tried  
> these two approaches:
>
>   <content name="file_list">
>     <{perl
>       @_=`ls -1 *.wmk`;
>       chomp(@_);
>       $_=join(' ', @_);
>       s/\.wmk//g;
>       $_;
>     }>
>   </content>
>   <for name="page" values=${file_list}>
>   ...
>
> and:
>
>
>   <for name="page" values=<{perl
>       @_=`ls -1 *.wmk`;
>       chomp(@_);
>       $_=join(' ', @_);
>       s/\.wmk//g;
>       $_;
>       }>
>       >
>   ...
>
> The perl block gets a list of all of the *.wmk files in a  
> directory, concatenates them into one string separated by spaces,  
> and removes the '.wmk' suffix. Now I want to iterate over each  
> value and generate an html file. The documenation hints at being  
> able to set a variable and then using that in a <for>  directive,  
> but I have not found an example that shows the syntax.
>
> Thanks for any help in advance.
> _______________________________________________
> WebMake-Talk mailing list
> WebMake-Talk at taint.org
> http://webmake.taint.org/mailman/listinfo/webmake-talk



More information about the WebMake-Talk mailing list