Lightweight, Component-based, and Database-oriented Web Application Framework

About | Overview | Documentation


Documentation > Modules and APIs > CGI_HTML_Map




The core module to render CGI parameters values inside the view template. In most cases developers not need to use this module directly since its implementation already supported internally inside CGI_Component module. Developers only need to prepare the view template (see section 1) and assign it to application component that is based on CGI_Component module.


1. View Template

Example of view template to render student information from CGI parameters "name", "course", and "year". The parts of CGI template-element named student_info (lines 09-14) are marked by the <!-- start_cgihtml_ name=student_info //--> and <!-- end_cgihtml_ //--> paired template tags. Component-type module assigned with this view template will have its process_CGIHTML function hooked and run when the main function to extract view template-elements process_Content is called. Read section 3 for example on how to override this hook function.

Also note that the CGI parameters are mapped into CGI template-elements using template word patterns as follows: name => $cgi_name_, course => $cgi_course_, and year => $cgi_year_.

  1 <html>                                                                  
  2 <head>                                                                  
  3 <title>Untitled Document</title>                                        
  4 <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  5 </head>                                                                 
  6 <body>                                                                  
  7 <!-- start_view_ //-->                                                  
  8 <!-- start_cgihtml_ name=student_info //-->                             
  9 Name: $cgi_name_                                                        
 10 <br />                                                                  
 11 Course: $cgi_course_                                                    
 12 <br />                                                                  
 13 Year: $cgi_year_                                                        
 14 <!-- end_cgihtml_ //-->                                                 
 15 <!-- end_view_ //->                                                     
 16 </body>                                                                 
 17 </html                                                                  

2. Instantiation and Basic Parameter Setting

The passed argument $cgi is other Webman-framework core module instance. The $cgi is an instance of GMM_CGI module.

my $cgi_HTML = new CGI_HTML_Map;

3. Processing Template Element Content


### $esc_mode can be 0 or 1
my $content = $cgi_HTML->get_HTML_Code;

4. Implementation Inside Hook Function

Please note that in most cases the implementation below is not required since it has been by default handled inside CGI_Component core module (the most top base-module of component-type modules).

sub process_CGIHTML { 
    my $this = shift @_;
    my $te = shift @_;

    my $cgi = $this->get_CGI;
    my $dbu = $this->get_DBU;
    my $db_conn = $this->get_DB_Conn;
    my $te_content = $te->get_Content;
    my $te_type_num = $te->get_Type_Num;
    my $te_type_name = $te->get_Name;
    ### Start process template-element's content.
    my $cgi_HTML = new CGI_HTML_Map;
    my $content = $cgi_HTML->get_HTML_Code;