Chapter 11
A better solution is to use a templating system. There are many templating 
systems available, most of which would meet this challenge with ease. However, 
CGI::Application includes support for HTML::Template,
4
 and the two have been 
specially designed to work well together.
5
 Listings 11 4 and 11 5 show how the 
exact same output could be generated using HTML::Template.
Listing 11 4. Message Entry Screen Implemented with HTML::Template
sub _edit {
  my $self = shift;
  my %options = @_;
  # load template for edit screen
  my $template = $self >load_tmpl( edit.tmpl );
  # include reply_id in hidden field if replying
  $template >param(reply_id => $reply_id) if exists $options{reply_id};
  # return template output
  return $template >output;
}
Listing 11 5. Message Entry Screen Template File edit.tmpl
  Message Editor
  

Enter Your Message Below

  
    Name: 

    Subject: 

    Message Body

    

    
    
4. I wrote HTML::Template while working for Jesse Erlbaum, the author of CGI::Application, at 
Vanguard Media (http://www.vm.com). It is, of course, available on CPAN!
5. However, if HTML::Template isn't your tool of choice, using an alternative templating system 
is as easy as implementing a replacement for the load_tmpl() method in your subclass.
266






footer




 

 

 

 

 Home | About Us | Network | Services | Support | FAQ | Control Panel | Order Online | Sitemap | Contact

web hosting perl

 

Our partners: PHP: Hypertext Preprocessor Best Web Hosting Java Web Hosting Inexpensive Web Hosting  Jsp Web Hosting

Cheapest Web Hosting Jsp Hosting Cheap Hosting

Visionwebhosting.net Business web hosting division of Web Design Plus. All rights reserved