"... why add the complexity of a separate HTML template ..."

Because someone added the complexity of an HTML coder to your project. Whenever i write a small app for myself, i usually just pick CGI.pm and be done with it, but anything that involves a team, i use a templating system. I started out with HTML::Template and we use HTML::Template were i work, but must confess that Template Toolkit is very fun stuff.

However, another issue arrises when you decide to store your menu in a database. Let's see CGI.pm do this easier! ;) (warning: untested)
$sth = $dbh->prepare("select title,width,height,param,alt from menu"); $sth->execute; $tmpl->param(menu => $sth->fetchall_arrayref({})); print header, $tmpl->output; __DATA__ <tmpl_loop menu> <span class="mitem"> <a title="<tmpl_var title>" href="?a=<tmpl_var param>"> <img height="<tmpl_var height>" border="0" src="i/<tmpl_var param>.png" alt="<tmpl_var alt>" width="<tmpl_var width>" /> &nbsp;<tmpl_var param>&nbsp; </a> </span> </tmpl_loop>
Also, if you use HTML::Template, you should only be using CGI.pm for three things (excluding uploads):
  1. to print the header
  2. to fetch the params
  3. to create form elements
You should not be mixing anything else. See Colorized HTML stack trace and my reply for what i think is a good CGI.pm to H::T conversion.

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)

In reply to Re: HTML::Template vs. CGI.pm by jeffa
in thread HTML::Template vs. CGI.pm by hacker

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.