The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.
[%#
  # IMPORTANT NOTE
  #   This documentation is generated automatically from source
  #   templates.  Any changes you make here may be lost.
  # 
  #   The 'docsrc' documentation source bundle is available for download
  #   from http://www.template-toolkit.org/docs.html and contains all
  #   the source templates, XML files, scripts, etc., from which the
  #   documentation for the Template Toolkit is built.
-%]
[% META book = 'Modules'
        page = 'Template'
%]
[%  WRAPPER toc;
	PROCESS tocitem 
	        title ="SYNOPSIS "
                subs  = [];
	PROCESS tocitem 
	        title ="DESCRIPTION"
                subs  = [];
	PROCESS tocitem 
	        title ="METHODS"
                subs  = [
                    "new(\\%config)",
		    "process(\$template, \\%vars, \$output, %options)",
		    "error()",
		    "service()",
		    "context()"
		];
	PROCESS tocitem 
	        title ="CONFIGURATION SUMMARY"
                subs  = [
                    "Template Style and Parsing Options",
		    "Template Files and Blocks",
		    "Template Variables",
		    "Runtime Processing Options",
		    "Caching and Compiling Options",
		    "Plugins and Filters",
		    "Compatibility, Customisation and Extension"
		];
	PROCESS tocitem 
	        title ="DIRECTIVE SUMMARY"
                subs  = [];
	PROCESS tocitem 
	        title ="AUTHOR"
                subs  = [];
	PROCESS tocitem 
	        title ="VERSION"
                subs  = [];
	PROCESS tocitem 
	        title ="COPYRIGHT"
                subs  = [];
    END
%]
<!-- Pod to HTML conversion by the Template Toolkit version 2 -->
[% WRAPPER section
    title="SYNOPSIS "
-%]<pre>  use Template;</pre>
<pre>  # some useful options (see below for full list)
  my $config = {
      INCLUDE_PATH =&gt; '/search/path',  # or list ref
      INTERPOLATE  =&gt; 1,               # expand &quot;$var&quot; in plain text
      POST_CHOMP   =&gt; 1,               # cleanup whitespace 
      PRE_PROCESS  =&gt; 'header',        # prefix each template
      EVAL_PERL    =&gt; 1,               # evaluate Perl code blocks
  };</pre>
<pre>  # create Template object
  my $template = Template-&gt;new($config);</pre>
<pre>  # define template variables for replacement
  my $vars = {
      var1  =&gt; $value,
      var2  =&gt; \%hash,
      var3  =&gt; \@list,
      var4  =&gt; \&amp;code,
      var5  =&gt; $object,
  };</pre>
<pre>  # specify input filename, or file handle, text reference, etc.
  my $input = 'myfile.html';</pre>
<pre>  # process input template, substituting variables
  $template-&gt;process($input, $vars)
      || die $template-&gt;error();</pre>
[%- END %]
[% WRAPPER section
    title="DESCRIPTION"
-%]<p>
This documentation describes the Template module which is the direct
Perl interface into the Template Toolkit.  It covers the use of the
module and gives a brief summary of configuration options and template
directives.  Please see [% ttlink('Template::Manual') -%] for the complete reference
manual which goes into much greater depth about the features and use
of the Template Toolkit.  The [% ttlink('Template::Tutorial') -%] is also available
as an introductory guide to using the Template Toolkit.
</p>
[%- END %]
[% WRAPPER section
    title="METHODS"
-%][% WRAPPER subsection
   title = "new(\\%config)"
-%]<p>
The new() constructor method (implemented by the Template::Base base
class) instantiates a new Template object.  A reference to a hash
array of configuration items may be passed as a parameter.
</p>
<pre>    my $tt = Template-&gt;new({
    	INCLUDE_PATH =&gt; '/usr/local/templates',
	    EVAL_PERL    =&gt; 1,
    }) || die $Template::ERROR, &quot;\n&quot;;</pre>
<p>
A reference to a new Template object is returned, or undef on error.
In the latter case, the error message can be retrieved by calling
error() as a class method (e.g. <code>'Template-&gt;error()'</code>) or by
examining the $ERROR package variable directly
(e.g. <code>'$Template::ERROR'</code>).
</p>
<pre>    my $tt = Template-&gt;new(\%config)
        || die Template-&gt;error(), &quot;\n&quot;;</pre>
<pre>    my $tt = Template-&gt;new(\%config)
        || die $Template::ERROR, &quot;\n&quot;;</pre>
<p>
For convenience, configuration items may also be specified as a list
of items instead of a hash array reference.  These are automatically
folded into a hash array by the constructor.
</p>
<pre>    my $tt = Template-&gt;new(INCLUDE_PATH =&gt; '/tmp', POST_CHOMP =&gt; 1)
	|| die $Template::ERROR, &quot;\n&quot;;</pre>
[%- END %]
[% WRAPPER subsection
   title = "process(\$template, \\%vars, \$output, %options)"
-%]<p>
The process() method is called to process a template.  The first
parameter indicates the input template as one of: a filename relative
to INCLUDE_PATH, if defined; a reference to a text string containing
the template text; or a file handle reference (e.g. IO::Handle or
sub-class) or GLOB (e.g. \*STDIN), from which the template can be
read.  A reference to a hash array may be passed as the second
parameter, containing definitions of template variables.
</p>
<pre>    $text = &quot;[% tt_start_tag %] INCLUDE header [% tt_end_tag %]\nHello world!\n[% tt_start_tag %] INCLUDE footer [% tt_end_tag %]&quot;;</pre>
<pre>    # filename
    $tt-&gt;process('welcome.tt2')
        || die $tt-&gt;error(), &quot;\n&quot;;</pre>
<pre>    # text reference
    $tt-&gt;process(\$text)
        || die $tt-&gt;error(), &quot;\n&quot;;</pre>
<pre>    # GLOB
    $tt-&gt;process(\*DATA)
        || die $tt-&gt;error(), &quot;\n&quot;;</pre>
<pre>    __END__
    [% tt_start_tag %] INCLUDE header [% tt_end_tag %]
    This is a template defined in the __END__ section which is 
    accessible via the DATA &quot;file handle&quot;.
    [% tt_start_tag %] INCLUDE footer [% tt_end_tag %]</pre>
<p>
By default, the processed template output is printed to STDOUT.  The
process() method then returns 1 to indicate success.  A third
parameter may be passed to the process() method to specify a different
output location.  This value may be one of: a plain string indicating
a filename which will be opened (relative to OUTPUT_PATH, if defined)
and the output written to; a file GLOB opened ready for output; a
reference to a scalar (e.g. a text string) to which output/error is
appended; a reference to a subroutine which is called, passing the
output as a parameter; or any object reference which implements a
'print' method (e.g. IO::Handle, Apache::Request, etc.) which will 
be called, passing the generated output as a parameter.
</p>
<p>
Examples:
</p>
<pre>    # output filename
    $tt-&gt;process('welcome.tt2', $vars, 'welcome.html')
        || die $tt-&gt;error(), &quot;\n&quot;;</pre>
<pre>    # reference to output subroutine
    sub myout {
    	my $output = shift;
	    ...
    }
    $tt-&gt;process('welcome.tt2', $vars, \&amp;myout)
        || die $tt-&gt;error(), &quot;\n&quot;;</pre>
<pre>    # reference to output text string
    my $output = '';
    $tt-&gt;process('welcome.tt2', $vars, \$output)
        || die $tt-&gt;error(), &quot;\n&quot;;
    
    print &quot;output: $output\n&quot;;</pre>
<p>
In an Apache/mod_perl handler:
</p>
<pre>    sub handler {
	my $req = shift;</pre>
<pre>        ...</pre>
<pre>	# direct output to Apache::Request via $req-&gt;print($output)
	$tt-&gt;process($file, $vars, $req) || do {
	    $req-&gt;log_reason($tt-&gt;error());
	    return SERVER_ERROR;
	};</pre>
<pre>	return OK;
    }</pre>
<p>
After the optional third output argument can come an optional
reference to a hash or a list of (name, value) pairs providing further
options for the output.  The only option currently supported is
&quot;binmode&quot; which, when set to any true value will ensure that files
created (but not any existing file handles passed) will be set to
binary mode.
</p>
<pre>    # either: hash reference of options
    $tt-&gt;process($infile, $vars, $outfile, { binmode =&gt; 1 })
        || die $tt-&gt;error(), &quot;\n&quot;;</pre>
<pre>    # or: list of name, value pairs
    $tt-&gt;process($infile, $vars, $outfile, binmode =&gt; 1)
        || die $tt-&gt;error(), &quot;\n&quot;;</pre>
<p>
Alternately, the binmode argument can specify a particular IO layer such 
as &quot;:utf8&quot;.
</p>
<pre>    $tt-&gt;process($infile, $vars, $outfile, binmode =&gt; ':utf8')
        || die $tt-&gt;error(), &quot;\n&quot;;</pre>
<p>
The OUTPUT configuration item can be used to specify a default output 
location other than \*STDOUT.  The OUTPUT_PATH specifies a directory
which should be prefixed to all output locations specified as filenames.
</p>
<pre>    my $tt = Template-&gt;new({
    	OUTPUT      =&gt; sub { ... },       # default
	    OUTPUT_PATH =&gt; '/tmp',
	...
    }) || die Template-&gt;error(), &quot;\n&quot;;</pre>
<pre>    # use default OUTPUT (sub is called)
    $tt-&gt;process('welcome.tt2', $vars)
        || die $tt-&gt;error(), &quot;\n&quot;;</pre>
<pre>    # write file to '/tmp/welcome.html'
    $tt-&gt;process('welcome.tt2', $vars, 'welcome.html')
        || die $tt-&gt;error(), &quot;\n&quot;;</pre>
<p>
The process() method returns 1 on success or undef on error.  The error
message generated in the latter case can be retrieved by calling the
error() method.  See also [% ttlink('CONFIGURATION SUMMARY') -%] which describes how
error handling may be further customised.
</p>
[%- END %]
[% WRAPPER subsection
   title = "error()"
-%]<p>
When called as a class method, it returns the value of the $ERROR package
variable.  Thus, the following are equivalent.
</p>
<pre>    my $tt = Template-&gt;new()
        || die Template-&gt;error(), &quot;\n&quot;;</pre>
<pre>    my $tt = Template-&gt;new()
        || die $Template::ERROR, &quot;\n&quot;;</pre>
<p>
When called as an object method, it returns the value of the internal
_ERROR variable, as set by an error condition in a previous call to
process().
</p>
<pre>    $tt-&gt;process('welcome.tt2')
        || die $tt-&gt;error(), &quot;\n&quot;;</pre>
<p>
Errors are represented in the Template Toolkit by objects of the
Template::Exception class.  If the process() method returns a false
value then the error() method can be called to return an object of
this class.  The type() and info() methods can called on the object to
retrieve the error type and information string, respectively.  The
as_string() method can be called to return a string of the form &quot;$type
- $info&quot;.  This method is also overloaded onto the stringification
operator allowing the object reference itself to be printed to return
the formatted error string.
</p>
<pre>    $tt-&gt;process('somefile') || do {
    	my $error = $tt-&gt;error();
	    print &quot;error type: &quot;, $error-&gt;type(), &quot;\n&quot;;
    	print &quot;error info: &quot;, $error-&gt;info(), &quot;\n&quot;;
	    print $error, &quot;\n&quot;;
    };</pre>
[%- END %]
[% WRAPPER subsection
   title = "service()"
-%]<p>
The Template module delegates most of the effort of processing templates
to an underlying Template::Service object.  This method returns a reference
to that object.
</p>
[%- END %]
[% WRAPPER subsection
   title = "context()"
-%]<p>
The Template::Service module uses a core Template::Context object for
runtime processing of templates.  This method returns a reference to 
that object and is equivalent to $template-&gt;service-&gt;context();
</p>
[%- END %]
[%- END %]
[% WRAPPER section
    title="CONFIGURATION SUMMARY"
-%]<p>
The following list gives a short summary of each Template Toolkit 
configuration option.  See [% ttlink('Template::Manual::Config') -%] for full details.
</p>
[% WRAPPER subsection
   title = "Template Style and Parsing Options"
-%]<ul>
<li><b>START_TAG, END_TAG</b><br>
<p>
Define tokens that indicate start and end of directives (default: '[% tt_start_tag %]' and 
'[% tt_end_tag %]').
</p>

<li><b>TAG_STYLE</b><br>
<p>
Set START_TAG and END_TAG according to a pre-defined style (default: 
'template', as above).
</p>

<li><b>PRE_CHOMP, POST_CHOMP</b><br>
<p>
Remove whitespace before/after directives (default: 0/0).
</p>

<li><b>TRIM</b><br>
<p>
Remove leading and trailing whitespace from template output (default: 0).
</p>

<li><b>INTERPOLATE</b><br>
<p>
Interpolate variables embedded like $this or ${this} (default: 0).
</p>

<li><b>ANYCASE</b><br>
<p>
Allow directive keywords in lower case (default: 0 - UPPER only).
</p>

</ul>
[%- END %]
[% WRAPPER subsection
   title = "Template Files and Blocks"
-%]<ul>
<li><b>INCLUDE_PATH</b><br>
<p>
One or more directories to search for templates.
</p>

<li><b>DELIMITER</b><br>
<p>
Delimiter for separating paths in INCLUDE_PATH (default: ':').
</p>

<li><b>ABSOLUTE</b><br>
<p>
Allow absolute file names, e.g. /foo/bar.html (default: 0).
</p>

<li><b>RELATIVE</b><br>
<p>
Allow relative filenames, e.g. ../foo/bar.html (default: 0).
</p>

<li><b>DEFAULT</b><br>
<p>
Default template to use when another not found.
</p>

<li><b>BLOCKS</b><br>
<p>
Hash array pre-defining template blocks.
</p>

<li><b>AUTO_RESET</b><br>
<p>
Enabled by default causing BLOCK definitions to be reset each time a 
template is processed.  Disable to allow BLOCK definitions to persist.
</p>

<li><b>RECURSION</b><br>
<p>
Flag to permit recursion into templates (default: 0).
</p>

</ul>
[%- END %]
[% WRAPPER subsection
   title = "Template Variables"
-%]<ul>
<li><b>VARIABLES, PRE_DEFINE</b><br>
<p>
Hash array of variables and values to pre-define in the stash.
</p>

</ul>
[%- END %]
[% WRAPPER subsection
   title = "Runtime Processing Options"
-%]<ul>
<li><b>EVAL_PERL</b><br>
<p>
Flag to indicate if PERL/RAWPERL blocks should be processed (default: 0).
</p>

<li><b>PRE_PROCESS, POST_PROCESS</b><br>
<p>
Name of template(s) to process before/after main template.
</p>

<li><b>PROCESS</b><br>
<p>
Name of template(s) to process instead of main template.
</p>

<li><b>ERROR</b><br>
<p>
Name of error template or reference to hash array mapping error types to
templates.
</p>

<li><b>OUTPUT</b><br>
<p>
Default output location or handler.
</p>

<li><b>OUTPUT_PATH</b><br>
<p>
Directory into which output files can be written.
</p>

<li><b>DEBUG</b><br>
<p>
Enable debugging messages.
</p>

</ul>
[%- END %]
[% WRAPPER subsection
   title = "Caching and Compiling Options"
-%]<ul>
<li><b>CACHE_SIZE</b><br>
<p>
Maximum number of compiled templates to cache in memory (default:
undef - cache all)
</p>

<li><b>COMPILE_EXT</b><br>
<p>
Filename extension for compiled template files (default: undef - don't
compile).
</p>

<li><b>COMPILE_DIR</b><br>
<p>
Root of directory in which compiled template files should be written
(default: undef - don't compile).
</p>

</ul>
[%- END %]
[% WRAPPER subsection
   title = "Plugins and Filters"
-%]<ul>
<li><b>PLUGINS</b><br>
<p>
Reference to a hash array mapping plugin names to Perl packages.
</p>

<li><b>PLUGIN_BASE</b><br>
<p>
One or more base classes under which plugins may be found.
</p>

<li><b>LOAD_PERL</b><br>
<p>
Flag to indicate regular Perl modules should be loaded if a named plugin 
can't be found  (default: 0).
</p>

<li><b>FILTERS</b><br>
<p>
Hash array mapping filter names to filter subroutines or factories.
</p>

</ul>
[%- END %]
[% WRAPPER subsection
   title = "Compatibility, Customisation and Extension"
-%]<ul>
<li><b>V1DOLLAR</b><br>
<p>
Backwards compatibility flag enabling version 1.* handling (i.e. ignore it) 
of leading '$' on variables (default: 0 - '$' indicates interpolation).
</p>

<li><b>LOAD_TEMPLATES</b><br>
<p>
List of template providers.
</p>

<li><b>LOAD_PLUGINS</b><br>
<p>
List of plugin providers.
</p>

<li><b>LOAD_FILTERS</b><br>
<p>
List of filter providers.
</p>

<li><b>TOLERANT</b><br>
<p>
Set providers to tolerate errors as declinations (default: 0).
</p>

<li><b>SERVICE</b><br>
<p>
Reference to a custom service object (default: Template::Service).
</p>

<li><b>CONTEXT</b><br>
<p>
Reference to a custom context object (default: Template::Context).
</p>

<li><b>STASH</b><br>
<p>
Reference to a custom stash object (default: Template::Stash).
</p>

<li><b>PARSER</b><br>
<p>
Reference to a custom parser object (default: Template::Parser).
</p>

<li><b>GRAMMAR</b><br>
<p>
Reference to a custom grammar object (default: Template::Grammar).
</p>

</ul>
[%- END %]
[%- END %]
[% WRAPPER section
    title="DIRECTIVE SUMMARY"
-%]<p>
The following list gives a short summary of each Template Toolkit directive.
See [% ttlink('Template::Manual::Directives') -%] for full details.
</p>
<ul>
<li><b>GET</b><br>
<p>
Evaluate and print a variable or value.
</p>
<pre>    [% tt_start_tag %]   GET variable [% tt_end_tag %]    # 'GET' keyword is optional</pre>
<pre>    [% tt_start_tag %]       variable [% tt_end_tag %]
    [% tt_start_tag %]       hash.key [% tt_end_tag %]
    [% tt_start_tag %]         list.n [% tt_end_tag %]
    [% tt_start_tag %]     code(args) [% tt_end_tag %]
    [% tt_start_tag %] obj.meth(args) [% tt_end_tag %]
    [% tt_start_tag %]  &quot;value: $var&quot; [% tt_end_tag %]</pre>

<li><b>CALL</b><br>
<p>
As per GET but without printing result (e.g. call code)
</p>
<pre>    [% tt_start_tag %]  CALL variable [% tt_end_tag %]</pre>

<li><b>SET</b><br>
<p>
Assign a values to variables.
</p>
<pre>    [% tt_start_tag %] SET variable = value [% tt_end_tag %]    # 'SET' also optional</pre>
<pre>    [% tt_start_tag %]     variable = other_variable
    	   variable = 'literal text @ $100'
    	   variable = &quot;interpolated text: $var&quot;
    	   list     = [ val, val, val, val, ... ]
    	   list     = [ val..val ]
    	   hash     = { var =&gt; val, var =&gt; val, ... }
    [% tt_end_tag %]</pre>

<li><b>DEFAULT</b><br>
<p>
Like SET above, but variables are only set if currently unset (i.e. have no
true value).
</p>
<pre>    [% tt_start_tag %] DEFAULT variable = value [% tt_end_tag %]</pre>

<li><b>INSERT</b><br>
<p>
Insert a file without any processing performed on the contents.
</p>
<pre>    [% tt_start_tag %] INSERT legalese.txt [% tt_end_tag %]</pre>

<li><b>INCLUDE</b><br>
<p>
Process another template file or block and include the output.  Variables
are localised.
</p>
<pre>    [% tt_start_tag %] INCLUDE template [% tt_end_tag %]
    [% tt_start_tag %] INCLUDE template  var = val, ... [% tt_end_tag %]</pre>

<li><b>PROCESS</b><br>
<p>
As INCLUDE above, but without localising variables.
</p>
<pre>    [% tt_start_tag %] PROCESS template [% tt_end_tag %]
    [% tt_start_tag %] PROCESS template  var = val, ... [% tt_end_tag %]</pre>

<li><b>WRAPPER</b><br>
<p>
Process the enclosed block WRAPPER ... END block then INCLUDE the 
named template, passing the block output in the 'content' variable.
</p>
<pre>    [% tt_start_tag %] WRAPPER template [% tt_end_tag %]
       content...
    [% tt_start_tag %] END [% tt_end_tag %]</pre>

<li><b>BLOCK</b><br>
<p>
Define a named template block for subsequent INCLUDE, PROCESS, etc., 
</p>
<pre>    [% tt_start_tag %] BLOCK template [% tt_end_tag %]
       content
    [% tt_start_tag %] END [% tt_end_tag %]</pre>

<li><b>FOREACH</b><br>
<p>
Repeat the enclosed FOREACH ... END block for each value in the list.
</p>
<pre>    [% tt_start_tag %] FOREACH variable = [ val, val, val ] [% tt_end_tag %]	  # either
    [% tt_start_tag %] FOREACH variable = list [% tt_end_tag %]                 # or
    [% tt_start_tag %] FOREACH list [% tt_end_tag %]                            # or 
       content...
       [% tt_start_tag %] variable [% tt_end_tag %]
    [% tt_start_tag %] END [% tt_end_tag %]</pre>

<li><b>WHILE</b><br>
<p>
Enclosed WHILE ... END block is processed while condition is true.
</p>
<pre>    [% tt_start_tag %] WHILE condition [% tt_end_tag %]
       content
    [% tt_start_tag %] END [% tt_end_tag %]</pre>

<li><b>IF / UNLESS / ELSIF / ELSE</b><br>
<p>
Enclosed block is processed if the condition is true / false.
</p>
<pre>    [% tt_start_tag %] IF condition [% tt_end_tag %]
       content
    [% tt_start_tag %] ELSIF condition [% tt_end_tag %]
	 content
    [% tt_start_tag %] ELSE [% tt_end_tag %]
	 content
    [% tt_start_tag %] END [% tt_end_tag %]</pre>
<pre>    [% tt_start_tag %] UNLESS condition [% tt_end_tag %]
       content
    [% tt_start_tag %] # ELSIF/ELSE as per IF, above [% tt_end_tag %]
       content
    [% tt_start_tag %] END [% tt_end_tag %]</pre>

<li><b>SWITCH / CASE</b><br>
<p>
Multi-way switch/case statement.
</p>
<pre>    [% tt_start_tag %] SWITCH variable [% tt_end_tag %]
    [% tt_start_tag %] CASE val1 [% tt_end_tag %]
       content
    [% tt_start_tag %] CASE [ val2, val3 ] [% tt_end_tag %]
       content
    [% tt_start_tag %] CASE [% tt_end_tag %]         # or [% tt_start_tag %] CASE DEFAULT [% tt_end_tag %]
       content
    [% tt_start_tag %] END [% tt_end_tag %]</pre>

<li><b>MACRO</b><br>
<p>
Define a named macro.
</p>
<pre>    [% tt_start_tag %] MACRO name &lt;directive&gt; [% tt_end_tag %]
    [% tt_start_tag %] MACRO name(arg1, arg2) &lt;directive&gt; [% tt_end_tag %]
    ...
    [% tt_start_tag %] name [% tt_end_tag %]
    [% tt_start_tag %] name(val1, val2) [% tt_end_tag %]</pre>

<li><b>FILTER</b><br>
<p>
Process enclosed FILTER ... END block then pipe through a filter.
</p>
<pre>    [% tt_start_tag %] FILTER name [% tt_end_tag %]			    # either
    [% tt_start_tag %] FILTER name( params ) [% tt_end_tag %]		    # or
    [% tt_start_tag %] FILTER alias = name( params ) [% tt_end_tag %]	    # or
       content
    [% tt_start_tag %] END [% tt_end_tag %]</pre>

<li><b>USE</b><br>
<p>
Load a &quot;plugin&quot; module, or any regular Perl module if LOAD_PERL option is
set.
</p>
<pre>    [% tt_start_tag %] USE name [% tt_end_tag %]			    # either
    [% tt_start_tag %] USE name( params ) [% tt_end_tag %]		    # or
    [% tt_start_tag %] USE var = name( params ) [% tt_end_tag %]	    # or
    ...
    [% tt_start_tag %] name.method [% tt_end_tag %]
    [% tt_start_tag %] var.method [% tt_end_tag %]</pre>

<li><b>PERL / RAWPERL</b><br>
<p>
Evaluate enclosed blocks as Perl code (requires EVAL_PERL option to be set).
</p>
<pre>    [% tt_start_tag %] PERL [% tt_end_tag %]
	 # perl code goes here
	 $stash-&gt;set('foo', 10);
	 print &quot;set 'foo' to &quot;, $stash-&gt;get('foo'), &quot;\n&quot;;
	 print $context-&gt;include('footer', { var =&gt; $val });
    [% tt_start_tag %] END [% tt_end_tag %]</pre>
<pre>    [% tt_start_tag %] RAWPERL [% tt_end_tag %]
       # raw perl code goes here, no magic but fast.
       $output .= 'some output';
    [% tt_start_tag %] END [% tt_end_tag %]</pre>

<li><b>TRY / THROW / CATCH / FINAL</b><br>
<p>
Exception handling.
</p>
<pre>    [% tt_start_tag %] TRY [% tt_end_tag %]
	 content
       [% tt_start_tag %] THROW type info [% tt_end_tag %]
    [% tt_start_tag %] CATCH type [% tt_end_tag %]
	 catch content
       [% tt_start_tag %] error.type [% tt_end_tag %] [% tt_start_tag %] error.info [% tt_end_tag %]
    [% tt_start_tag %] CATCH [% tt_end_tag %]	# or [% tt_start_tag %] CATCH DEFAULT [% tt_end_tag %]
	 content
    [% tt_start_tag %] FINAL [% tt_end_tag %]
       this block is always processed
    [% tt_start_tag %] END [% tt_end_tag %]</pre>

<li><b>NEXT</b><br>
<p>
Jump straight to the next item in a FOREACH/WHILE loop.
</p>
<pre>    [% tt_start_tag %] NEXT [% tt_end_tag %]</pre>

<li><b>LAST</b><br>
<p>
Break out of FOREACH/WHILE loop.
</p>
<pre>    [% tt_start_tag %] LAST [% tt_end_tag %]</pre>

<li><b>RETURN</b><br>
<p>
Stop processing current template and return to including templates.
</p>
<pre>    [% tt_start_tag %] RETURN [% tt_end_tag %]</pre>

<li><b>STOP</b><br>
<p>
Stop processing all templates and return to caller.
</p>
<pre>    [% tt_start_tag %] STOP [% tt_end_tag %]</pre>

<li><b>TAGS</b><br>
<p>
Define new tag style or characters (default: [% tt_start_tag %] [% tt_end_tag %]).
</p>
<pre>    [% tt_start_tag %] TAGS html [% tt_end_tag %]
    [% tt_start_tag %] TAGS &lt;!-- --&gt; [% tt_end_tag %]</pre>

<li><b>COMMENTS</b><br>
<p>
Ignored and deleted.
</p>
<pre>    [% tt_start_tag %] # this is a comment to the end of line
       foo = 'bar'
    [% tt_end_tag %]</pre>
<pre>    [% tt_start_tag %]# placing the '#' immediately inside the directive
        tag comments out the entire directive
    [% tt_end_tag %]</pre>

</ul>
[%- END %]
[% WRAPPER section
    title="AUTHOR"
-%]<p>
Andy Wardley &lt;abw@wardley.org&gt;
</p>
<p>
[% ttlink('http://wardley.org/', 'http://wardley.org/') -%]
</p>
[%- END %]
[% WRAPPER section
    title="VERSION"
-%]<p>
Template Toolkit version 2.19, released on 27 April 2007.
</p>
[%- END %]
[% WRAPPER section
    title="COPYRIGHT"
-%]<pre>  Copyright (C) 1996-2007 Andy Wardley.  All Rights Reserved.</pre>
<p>
This module is free software; you can redistribute it and/or
modify it under the same terms as Perl itself.
</p>
[%- END %]