On Thu, 27 Jul 2000, Roger Espel Llima wrote:
> On Thu, Jul 27, 2000 at 01:28:06PM +0200, Darko Krizic wrote:
> > There is one big difference in the enhydra approach: The templates are
> > standard HTML, because the id tag is part of the HTML standard. The
> > designer can create the whole site and make a dry test, because all
> > links even work. The tags (with ids) can contain valid values.
i know it's already been mentioned in this thread in passing, but i'd like
to stress how easy i've found it is to work with HTML::Template. the
templates are straight HTML w/obvious and easy-to-work-with template tags
embedded, like so:
<html>
<head>
<title> ABC, Co. Website </title>
</head>
<body>
<h1> ABC, Co. Website </h1>
<hr>
Welcome, <tmpl_var name=customer_name>.
<p>
asdf asdf adsf asdf asdf asdf asdf afs asdf asdf asdf asdf
</p>
<p>
<tmpl_if name=print_data>
<table>
<tr>
<th> First Col </th>
<th> Second Col </th>
</tr>
<tmpl_loop name=data>
<tr>
<td> <tmpl_var name=column_one> </td>
<td> <tmpl_var name=column_two> </td>
</tr>
</tmpl_loop>
</table>
<tmpl_else>
I'm sorry, but no data was returned.
</tmpl_if>
</p>
</body>
</html>
that's a simple example, but you can see that you have some rudimentary
control structures (if, loop) and simple variable substitution. the perl
code controlling it can be fairly lightweight, too.
my $sth = $db->prepare($sql);
$sth->execute;
my (@data, $hashref);
push @data, $hashref while $hashref = $sth->fetchrow_hashref;
my $t = HTML::Template->new(filename => '/path/to/templates/foo.tmpl');
$t->param('customer_name' => 'Tom Jones',
'print_data' => (@data) ? 1 : 0,
'data' => \@data);
$r->print($t->output);
HTML::Template may not solve all your problems, but if you need something
quick, i think it's a pretty good solution.
ky