They actually do neither ... they are templating modules and
have no responsibility of producing valid HTML - that's up
to the HTML coder. As for being overkill, well ... the more
you use these tools, the quicker you get at coding with
them. You can see an example that i am proud of over at
4Re: How do I extract text from an HTML page? that uses HTML::Template. The template is
stored inside DATA - creating a new H::T object that uses
the DATA filehandle is a snap:
my $template = HTML::Template->new(filehandle => \*DATA);
For the Template-Toolkit quick and simple scripts, check
out Inline::TT, it's slow as hell, but when you
combine it with Class::DBI you get some amazing
results. I am nearly finished with my C::D mini-tut that
will demonstrate using C::D with multiple tables, but here
is a snippet just to show you the power of the Class::DBI
and Template combo. (and by the way, i learned most of this
from How
to Avoid Writing Code and the
poop-group
mailing list)
use strict;
use warnings;
use DVD::movie;
use Inline 'TT';
print DVD(movies => [DVD::movie->retrieve_all]);
__DATA__
__TT__
[% BLOCK DVD %]
[% FOREACH movie = movies %]
<img src="http://dvd.unlocalhost.com/images/[% movie.id %].jpg" ali
+gn="right" />
<h2>[% movie.title %]</h2>
<ul>
<li> Year - [% movie.year %]</li>
<li>Added - [% movie.timestamp %]</li>
<li>Directors:</li>
<ul>
[% FOREACH director = movie.directors %]
<li>[% director.name %]</li>
[% END %]
</ul>
<li>Writers:</li>
<ul>
[% FOREACH writer = movie.writers %]
<li>[% writer.name %]</li>
[% END %]
</ul>
<li>Genres:</li>
<ul>
[% FOREACH genre = movie.genres %]
<li>[% genre.name %]</li>
[% END %]
</ul>
</ul>
<br clear="right" />
[% END %]
[% END %]
That's just too easy. ;)
jeffa
L-LL-L--L-LL-L--L-LL-L--
-R--R-RR-R--R-RR-R--R-RR
B--B--B--B--B--B--B--B--
H---H---H---H---H---H---
(the triplet paradiddle with high-hat)
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|