CGI-Template

 view release on metacpan or  search on metacpan

lib/CGI/Template.pm  view on Meta::CPAN


If CGI::Template is called from a script called "welcome":

  #!/usr/bin/perl -w
  use strict;

  use CGI::Template;
  my $t = new CGI::Template;

  my $title = "Welcome";
  my $menu  = "Menu";
  my $text  = "Hello world.";

  print $t->header();
  print $t->content(
     TITLE => $title,
     MENU  => $menu,
     TEXT  => $text,
  );

And the contents of cgi-bin/templates/welcome.html are as follows:

lib/CGI/Template.pm  view on Meta::CPAN

Then the resulting output of the "welcome" script will be:

  Content-type: text/html

  <!DOCTYPE html>
  <html>
    <head>
       <title>Welcome</title>
    </head> 
    <body>
       <div id="menu">Menu</div>
       <div id="content">Hello world.</div>
    </body>
  </html>


=head2 $t->get_template()

Requres a string argument. Returns a template retrieved from the file named $string within the CGI::Template directory.  This is useful to reduce the amount of time spent editing template content that is used on many pages throughout your web applica...

  my $menu = $t->get_template( "menu" );



( run in 1.175 second using v1.01-cache-2.11-cpan-49f99fa48dc )