title: File Patterns
src: read_file( SELF )
sidebar: read_file( sidebar.inc )
files: file_glob( "img/*.jpg" )
----
<h2>File Patterns</h2>
<blockquote>
<p>There is a special kind of per-page variable, using <tt>file_glob</tt>, which sets
up a data-structure which is used for a list. Lists are documented fully in the
<a href="http://search.cpan.org/perldoc?HTML%3A%3ATemplate">HTML::Template</a> documentation, but in brief if you have this structure:</p>
<pre>
index.wgn
IMAGE1.jpg
IMAGE2.jpg
IMAGE3.jpg
</pre>
<p>You can setup a loop to hold the names of each file via:</p>
<pre>
files: file_glob( "IMAGE*.jpg" )
</pre>
<p>Then this, in your template, will allow you to see each of them:</p>
<pre>
<!-- tmpl_loop name='files' -->
<img src= "<!-- tmpl_var name='file' -->">
<!-- /tmpl_loop -->
</pre>
<p>Here is a live example:</p>
<!-- tmpl_loop name='files' -->
<p><img src="<!-- tmpl_var name='file' -->" /></p>
<!-- /tmpl_loop -->
</blockquote>