Hi Drew,
> I'm the one who volunteered, and then I went on vacation for a 2 weeks.
> I have decided I will have a bare minimum draft done within a week. And
> then, as Matt suggested, people can just send
> suggestions/corrections/additions and the document will grow. When I
> have a draft, I'll post it to the list.
I'm new to this list, and I'd like to make a small contribution to the
HTML Template Comparison Sheet.
I've been using Text::Template for some time now, and I really enjoy using
it because 1) it's fast, 2) it's small, just 28kb and 3) it uses Perl as
scripting language.
>From the author's words:
"When people make a template module like this one, they almost always
start by inventing a special syntax for substitutions. For example, they
build it so that a string like %%VAR%% is replaced with the value of
$VAR. Then they realize the need extra formatting, so they put in some
special syntax for formatting. Then they need a loop, so they invent a
loop syntax. Pretty soon they have a new little template language."
"This approach has two problems: First, their little language is
crippled. If you need to do something the author hasn't thought of, you
lose. Second: Who wants to learn another language? You already know
Perl, so why not use it?"
That's a great concept. Anyway, I have tweaked the code a little, now
allows you to to make expressions like this one:
<? foreach $name (@names) { ?>
Name: <?=$name?> <P>
Job: <?=$job{$name}?> <P>
<P>
<? } ?>
Notice the <?=$variable?> construction, It's the only "magic" that you
have to know. If you already know Perl, the code is much cleaner than the
HTML::Template counterpart, which would be something like this:
<TMPL_LOOP NAME=EMPLOYEE_INFO>
Name: <TMPL_VAR NAME=NAME> <P>
Job: <TMPL_VAR NAME=JOB> <P>
<P>
</TMPL_LOOP>
Futhermore, with Text::Template you can access methods and modules
directly from the templates. For instance:
<? my @emp = &main::sql("select name,job from employee"); ?>
<? my @emp = $employee->list(); ?>
The only problem with Text::Template is that it fails on taint checks.
However, because this module is very flexible, I believe that it's easy to
fix it by "untainting" the template before parsing it!
If anyone is curious about the Text::Template module, take a look at the
author's homepage at: http://www.plover.com/~mjd/perl/
Best wishes,
Nelson
__________________________________________________________________
Nelson Ferraz Insite - Solucoes Internet
e-mail: [EMAIL PROTECTED] http://www.insite.com.br/
Re: HTML Template Comparison Sheet ETA
Nelson Correa de Toledo Ferraz Mon, 28 Aug 2000 15:51:04 -0700
- Content negotiation Was: Re: HTML Template ... David Hodgkinson
- Question about $sth->finish; Vladislav Safronov
- Re: Question about $sth->finish... Matt Sergeant
- RE: Question about $sth->fi... Vladislav Safronov
- RE: Question about $sth-&g... Matt Sergeant
- Re: Question about $sth->fi... Keith G. Murphy
- Re: Question about $sth-&g... Matt Sergeant
- Re: Question about $sth->finish... Tim Bunce
- RE: Question about $sth->fi... Vladislav Safronov
- Re: HTML Template Comparison Sheet ETA Drew Taylor
- Re: HTML Template Comparison Sheet ETA Nelson Correa de Toledo Ferraz
- Re: HTML Template Comparison Sheet... Drew Taylor
- Re: HTML Template Comparison Sheet... Sam Tregar
- Re: HTML Template Comparison S... Nelson Correa de Toledo Ferraz
- Re: HTML Template Comparis... Matt Sergeant
- Re: HTML Template Com... brian moseley
- Re: HTML Template Com... Matt Sergeant
- Re: HTML Template Com... brian moseley
- Re: HTML Template Com... Matt Sergeant
- Re: HTML Template Com... brian moseley
- Re: HTML Template Com... David Hodgkinson
