On Mon, 4 Sep 2000, Nelson Correa de Toledo Ferraz wrote:
> I still think that this:
>
> <? foreach $name (@names) { ?>
> Name: <?=$name?> <P>
> Job: <?=$job{$name}?> <P>
> <? } ?>
>
> Is cleaner (well, as much as perl can be :-)) than this:
>
> <TMPL_LOOP NAME=EMPLOYEE_INFO>
> Name: <TMPL_VAR NAME=NAME> <P>
> Job: <TMPL_VAR NAME=JOB> <P>
> </TMPL_LOOP>
And I still think that:
<DIV CLASS="employee_info">
Name: <SPAN CLASS="text::name">John Q. Public</SPAN><BR>
Job: <SPAN CLASS="text::job">mod_perl guru</SPAN>
</DIV>
is cleaner still: *pure* HTML (no fake elements) that any web
tool will understand and dummy-content so the page designer can
see the end-product before any code is written.
Another benefit in not mixing any code in the template is that
the web page designer can wake up tomorrow and change the
template to:
<TABLE>
<TR>
<TH>Name</TH>
<TH>Job</TH>
</TR>
<TR CLASS="employee_info">
<TD CLASS="text::name">John Q. Public</TD>
<TD CLASS="text::job">mod_perl guru</TD>
</TR>
</TABLE>
and not a single line of the associated Perl code has to
change. So when either the web page designers or the marketers
(*shudder*) decide that the web page needs some snazzing up,
they can snazz them up all they want and they don't have to bug
the programmers to change anything.
See <http://www.best.com/~pjl/software/html_tree/> for details.
(I've got the day off today so I'm gonna try to figure out how
to get this thing submitted to CPAN.)
> And the first one has two major advantages: 1) requires less code in the
> Perl modules
But that's where the code belongs.
> and 2) allows designers to know how Perl looks like.
Web designers don't care what the Perl looks like.
> I agree that one shouldn't put lots of code inside of a template, but
> variables and loops are better expressed in Perl than in a "little crippled
> language".
I agree: Perl should be used to its full ability, but none of it
should be in the template.
- Paul