NAME

CGI::Embedder - Module for HTML embedding in your Perl programs.


SYNOPSIS

  #!/usr/local/bin/perl -w 
  use CGI::Embedder; 
  ...
  CGI::Embedder::ExpandFile("tmpl.htm");
  # where tmpl.htm is:
  <h1>Hello</h1>
  <?for(my $i=10; $i<20; $i++) {?>
    Hello, world N$i! 
    $i * $i = <?=$i*$i?><br>
  <?}?>


DESCRIPTION

This module is used to parse e-perl templates.

use CGI::Embedder
Loads the module core. No subroutines are exported.

Compile($content [,string \&filter_func(string $input)])
Converts all the <?...?> sequences in $content to print series. You may then run eval for resulting string to print out the template. Template example:
  Text with variable: $variable.
  Running: <?do_some_work(); do_another_work()?>
  Product is: <?=$a*$b*$c?>

If &filter_func defined, this function is used to parse the the HTML placed outside code tags.

Expand($templ [,$cacheId] [,$filename])
Compiles and then expands (runs) the template $templ. Compiled code is cached using $cacheId hash-code. Parameter $filename is used ONLY in resulting error messages. If your need to get the output as string, use CGI::WebOut to grab it:
  use CGI::WebOut;
  my $str=grab { CGI::Embedder::Expand($template) };

ExpandFile($filename)
Does the same as Expand(), but always expands the file $filename content.


AUTHOR

Dmitry Koteroff <dk@dklab.ru>, http://www.dklab.ru