[roch-pm] Techniques for templates

David Maier djm at rochester.rr.com
Wed Oct 25 23:09:55 CDT 2000


The way i do is probably very ugly, but i split my page into 2 parts. The
first part being the half of the page before where i want to insert the
info, and the second part is the other half of my page. I put those parts
into each its own sub. Whenever i want to print info to a page, i just do
something like this:

&html1;
print whatever here;
&html2;

If you can split your page so that there's 1 main section that is updated,
then this works pretty well. I'm not sure about how great an idea it is
though. I'm semi-new to the perl scene, and any advances on my method would
be appreciated.

Dave Maier
- http://www.thelookingman.com -


----- Original Message -----
From: "Richard Martin Woodward" <RichardWoodward at hotmail.com>
To: <rochester-pm-list at happyfunball.pm.org>
Sent: Wednesday, October 25, 2000 9:36 PM
Subject: Re: [roch-pm] Techniques for templates


> 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
>

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



More information about the Rochester-pm mailing list