CGI Application Modules for CPAN
    
      
    
  
Listing 11 4 shows the new _edit() method. Now all the code does is load the 
template using CGI::Application's load_tmpl() method. This method takes the 
name of an HTML::Template template file and calls HTML::Template >new() to load 
it, returning the new HTML::Template object. Next, if the user is replying to a 
message, the reply_id template parameter is set using HTML::Template's param()
method. This method works similarly to the CGI.pm param() method, but instead 
of accessing CGI parameters it sets variables declared in the template with .
Finally, the template output is generated using the output() method and 
returned. Yes, it really is that simple!
Listing 11 5, the template file (edit.tmpl) used in Listing 11 4, is a bit more 
complicated, but you can blame HTML for that. It's unfortunate that no one 
thought to ask Larry Wall to design the markup language for the Web! However, 
since this is mostly plain HTML, there are many skilled designers available to take 
this stuff off your hands. The only part of this template that's not plain HTML is the 
section that optionally sets up the reply_id parameter:
    
      
    
This section uses two of HTML::Template's special tags,  and ,
to conditionally include the reply_id hidden field in the form. I don't have time 
to explore HTML::Template fully here for that see the HTML::Template 
documentation.
The benefits of this approach are numerous. By separating the HTML from the 
code that drives the application, both can be made simpler. Furthermore, people 
with different skills can work more efficiently on the part of the application they 
know best. In this example, I could spend my time working on adding features to 
the BBS.pm file while an HTML designer works on making the form easier to look at 
and use. In addition, as I'll demonstrate later, a proper use of templating is critical 
to allowing your CGI applications to be reused by others.
26
267
7






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