in reply to Organizational strategies when using HTML::Template

Hagbone, great question and welcome to HTML::Template. In answer to your question, in our shop we keep all *.tmpl files in a directory off the root directory. We only have two designers and they know what they are doing, so protecting the files from harm is not a huge concern. I still maintain the Perl in the cgi-bin.

My biggest learning mistake with H::T was not knowing and taking advantage of all its features. Be sure to read the CPAN docs thoroughly, and memorize jeffa's terrific tutorial, especially the "Bag of Tricks" section (also see Ovid's and gav^'s) The key to planning your workflow is knowing all that H::T can do.

I also replied to a larger thread, all of which you should take a look at (kiat had a lot of posts on this topic back in December, so check his posts).

In any case, your designer's will love you.

—Brad
"A little yeast leavens the whole dough."
  • Comment on Re: Organizational strategies when using HTML::Template

Replies are listed 'Best First'.
Re: Re: Organizational strategies when using HTML::Template
by chanio (Priest) on Jan 12, 2004 at 02:23 UTC
    (copied from CGI::Session's Cookbook Tutorial.pm)

    ...associate the $session object with that of HTML::Template:

    $template = new HTML::Template(filename=>"some.tmpl", associate=>$session );

    Now in your ``some.tmpl'' template you can access the above history like so:

    <!-- left menu starts --> <table width="170"> <tr> <th> last visited pages </th> </tr> <TMPL_LOOP NAME=HISTORY> <tr> <td> <a href="<TMPL_VAR NAME=LINK>"> <TMPL_VAR NAME=TITLE> </a> </td> </tr> </TMPL_LOOP> </table> <!-- left menu ends -->

    Please, observe that the same hash ref. ($session object) is applied directly in the HT since it's structure is the same. So you could mention the same hash keys in the template (see the LOOP NAME)

    I have also found out that CGI::Application has some special functions reserved for HT in this same fashion (and you don't need to declare HT in it).

    Refering to the place of the templates, I have discovered that CGI::Framework (similar to CA) needs to name the template's extensions as .html. In this case, you wouldn't be able to mix templates with html files in the same directory. So, having them outside the reach of your server is clever: because you don't have to change the servers' extensions to prevent opening a template instead of a normal html file.

    With all these 'canned' programming experience of the mentioned modules, it is easy to become a famous webmaster in a few months!