[roch-pm] Techniques for templates

Richard Martin Woodward RichardWoodward at hotmail.com
Wed Oct 25 20:36:41 CDT 2000


Hi, Brian.

Another way is to--"use HTML::Template;".

This allows your template to be customized independently
of your perl program.  Of course, the template can be
modified by your "user," and this can be an attractive part
of your end product.

A lot of work went into the design of the HTML::Template
module.  You don't want to reinvent that wheel each time you
write an CGI application to produce customized HTML.

I followed that approach with my HTML_Search program, and
everything went smoothly as I tested it on my PC running Win98
and the Apache server.  Unfortunately, the www host I use to run
HTML_Search (see http://www.richardwoodward.com)
doesn't currently support HTML::Template. But I was able to
write my own stripped-down version (about 150 lines of Perl)
to replace HTML:Template.

The beauty of the HTML::Template; approach is that you are
forced to separate algorithmic considerations (i.e., figuring out
*what* to show) from display considerations (i.e., how to show it)
as you program an application to be HTML:Template compatible.

In summary, I recommend using HTML::Template when it is
important to have a clean interface to your (separate) HTML
display code.

Regards,
Richard Martin Woodward
perl_monger at richardwoodward.com

----- Original Message -----
From: "Brian Mathis" <bmathis at directedge.com>
To: "Rochester Perl Mongers" <rochester-pm-list at happyfunball.pm.org>
Sent: Wednesday, October 25, 2000 9:17 PM
Subject: [roch-pm] Techniques for templates


> I assume there are a lot of CGI programmers out here, and I was wondering
> how people handle printing out customized pages back to the browser.  I
can
> think of a few different techniques on how this could be done:
> 1. Store the html in a file, and search & replace on tokens in that file
> 2. actully embed the html code in the perl script itself, then print it
> all out with $vars automatically updated
> 3. use CGI.pm to handle printing the html tags for you
>
> I personally use #1, but I was wondering what other people use.

--
For information on unsubscribing from this list, please visit
http://rochester.pm.org



More information about the Rochester-pm mailing list