#!/usr/bin/perl -w $| = 1; use Website; my $Website = Website->new( file => 'website-tpl.htm' ); $Website->let('firstname', 'Reto' ); $Website->let('lastname' , 'Hersiczky'); $Website->block('demoBlock', print => $ENV{QUERY_STRING} eq 'block=1' ? 1 : 0); # Populate three records my @table_data = ( "John Doe Washington" , "Foo Bar Neverland" , "Tiger Woods Florida" , ); my $i = 0; my @rowcolors = ('#e0e0e0', 'white'); foreach (@table_data) { my ($firstname, $lastname, $place) = split /\t/; $Website->let('bcol', $rowcolors[$i++ % 2], 'tableRow'); # -- Assign values to data cells (one table row) $Website->let('firstname', $firstname, 'tableRow'); $Website->let('lastname', $lastname , 'tableRow'); $Website->let('place' , $place , 'tableRow'); } $Website->print( contentType_is_set => 0, quiet => 1 );
<html>
<p>
Variable <i>firstname</i>: <b>{{firstname}}</b> <br> <br>
Variable <i>lastname </i>: <b>{{lastname}}</b>
</p>
<table cellspacing="0" cellpadding="3" border="1">
<tr bgcolor="#cccccc">
<th align="left">Firstname</th>
<th align="left">Lastname </th>
<th align="left">Place </th>
</tr>
<!-- {{BLOCK tableRow}} -->
<tr bgcolor="{{bcol}}"> <td>{{firstname}}</td> <td>{{lastname}}</td> <td>{{place}}</td></tr>
<!-- {{END}} -->
<tr> <td colspan="3"> End of Table </td> </tr>
</table>
<!-- {{BLOCK demoBlock}} -->
<br>
[ <a href="/cgi-bin/website.pl?block=0">
<b>Switch *off* the following block</b></a> ]<br>
<p class="rightMargin">
text text text text text text text text text text text text text text
text text text text text text text text text text text text text text
text text text text text text text text text text text text text text
</p>
<!-- {{END}} -->
</html>
copyright by retoh - created with mytexi