|
|
Choosing A Webhost: |
Re: Re: H::T future: msg#00042lang.perl.modules.html-template
Karen J. Cravens wrote: On Tue, 9 Dec 2003, Puneet Kishor wrote: well, now that you put it that way, I feel I might be the one who is not really understanding what you all are saying, and hence, am perhaps barking tangentially ;-). Anyway, here are a couple of examples (there might be typos, but should be sufficient for explanation purpose). Does this make sense? Btw, I prefer Setup 1 over Setup 2 because designer types can actually visualize different pages and the entire site layout -- even more easily if they are using Golive or Dreamweaver or somesuch. ======================================================================== Setup 1. Using separate templates for each page ======================================================================== .. my $act = !defined(param('act')) ? 'welcome' : scalar(param('act')); # Invoke template based on act. There are separate templates for # each page. The templates are stored in a separate directory so # "designer" types can work on them without worrying the scripts. my $template = HTML::Template->new(filename => "$act.tmpl"); $template->param('content'=>&content($act), 'title'=>&title($act)); .. -------------------------------------------------------------------- meantime, in the templates (this one is called "welcome.tmpl") -------------------------------------------------------------------- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <head> <title><tmpl_var title></title> <link rel="stylesheet" type="text/css" href="../myapp.css"> </head> <body> <div class="content"><tmpl_var content></div> </body> </html> ====================================================================== Setup 2. Using one template for all the pages ====================================================================== .. my $act = !defined(param('act')) ? 'welcome' : scalar(param('act')); # Invoke template. A single template for the entire app, but the # header and footer can be changed based on act. The templates are # stored in a separate directory so "designer" types can work on # them without worrying the scripts. my $template = HTML::Template->new(filename => 'index.tmpl'); $template->param('content'=>&content($act), 'title'=>&title($act)); .. -------------------------------------------------------------------- meantime, in the templates -------------------------------------------------------------------- header.tmpl -------------------------------------------------------------------- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <head> <title><tmpl_var title></title> <link rel="stylesheet" type="text/css" href="../myapp.css"> </head> <body> -------------------------------------------------------------------- index.tmpl -------------------------------------------------------------------- <tmpl_include header.tmpl> <div class="content"><tmpl_var content></div> <tmpl_include footer.tmpl> -------------------------------------------------------------------- footer.tmpl -------------------------------------------------------------------- <hr> another app served by the wonders of Perl and HTML::Template </body> </html> ------------------------------------------------------- This SF.net email is sponsored by: IBM Linux Tutorials. Become an expert in LINUX or just sharpen your skills. Sign up for IBM's Free Linux Tutorials. Learn everything from the bash shell to sys admin. Click now! http://ads.osdn.com/?ad_id=1278&alloc_id=3371&op=click
|
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | Re: Re: H::T future, Cees Hek |
|---|---|
| Next by Date: | Re: Re: H::T future, Karen J. Cravens |
| Previous by Thread: | Re: Re: H::T future, Karen J. Cravens |
| Next by Thread: | Re: Re: H::T future, Karen J. Cravens |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
Free MagazinesCisco NewsReceive a free quarterly e-newsletter with exclusive articles on how Cisco IT uses its own products and solutions to enable the business. subscribe Systems Management News, the newspaper for IT systems administration and data center managers! Each issue of Systems Management News is chock-full of news and analysis to help you understand what's happening in your field. subscribe The Enterprise Newsweekly eWeek is the essential technology information source for builders of e-business. subscribe Oracle Magazine Oracle Magazine contains technology strategy articles, sample code, tips, Oracle and partner news, how to articles for developers and DBAs, and more. Oracle (NASDAQ: ORCL) is the world's largest enterprise software company. subscribe Total Telecom Total Telecom is "The Economist of the communications industry". subscribe |