[%# # 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 = 'Manual' page = 'Config' %] [% WRAPPER toc; PROCESS tocitem title ="DESCRIPTION" subs = [ "Template Style and Parsing Options", "Template Files and Blocks", "Template Variables", "Template Processing Options", "Template Runtime Options", "Caching and Compiling Options", "Plugins and Filters", "Compatibility, Customisation and Extension" ]; PROCESS tocitem title ="AUTHOR" subs = []; PROCESS tocitem title ="VERSION" subs = []; PROCESS tocitem title ="COPYRIGHT" subs = []; END %] [% WRAPPER section title="DESCRIPTION" -%][% WRAPPER subsection title = "Template Style and Parsing Options" -%] [%- END %] [% WRAPPER subsection title = "Template Files and Blocks" -%] [%- END %] [% WRAPPER subsection title = "Template Variables" -%] [%- END %] [% WRAPPER subsection title = "Template Processing Options" -%]

The following options are used to specify any additional templates that should be processed before, after, around or instead of the template passed as the first argument to the Template process() method. These options can be perform various useful tasks such as adding standard headers or footers to all pages, wrapping page output in other templates, pre-defining variables or performing initialisation or cleanup tasks, automatically generating page summary information, navigation elements, and so on.

The task of processing the template is delegated internally to the Template::Service module which, unsurprisingly, also has a process() method. Any templates defined by the PRE_PROCESS option are processed first and any output generated is added to the output buffer. Then the main template is processed, or if one or more PROCESS templates are defined then they are instead processed in turn. In this case, one of the PROCESS templates is responsible for processing the main template, by a directive such as:

    [% tt_start_tag %] PROCESS $template [% tt_end_tag %]

The output of processing the main template or the PROCESS template(s) is then wrapped in any WRAPPER templates, if defined. WRAPPER templates don't need to worry about explicitly processing the template because it will have been done for them already. Instead WRAPPER templates access the content they are wrapping via the 'content' variable.

    wrapper before
    [% tt_start_tag %] content [% tt_end_tag %]
    wrapper after

This output generated from processing the main template, and/or any PROCESS or WRAPPER templates is added to the output buffer. Finally, any POST_PROCESS templates are processed and their output is also added to the output buffer which is then returned.

If the main template throws an exception during processing then any relevant template(s) defined via the ERROR option will be processed instead. If defined and successfully processed, the output from the error template will be added to the output buffer in place of the template that generated the error and processing will continue, applying any WRAPPER and POST_PROCESS templates. If no relevant ERROR option is defined, or if the error occurs in one of the PRE_PROCESS, WRAPPER or POST_PROCESS templates, then the process will terminate immediately and the error will be returned.

[%- END %] [% WRAPPER subsection title = "Template Runtime Options" -%] [%- END %] [% WRAPPER subsection title = "Caching and Compiling Options" -%] [%- END %] [% WRAPPER subsection title = "Plugins and Filters" -%] [%- END %] [% WRAPPER subsection title = "Compatibility, Customisation and Extension" -%] [%- END %] [%- END %] [% WRAPPER section title="AUTHOR" -%]

Andy Wardley <abw@wardley.org>

[% ttlink('http://wardley.org/', 'http://wardley.org/') -%]

[%- END %] [% WRAPPER section title="VERSION" -%]

Template Toolkit version 2.19, released on 27 April 2007.

[%- END %] [% WRAPPER section title="COPYRIGHT" -%]
  Copyright (C) 1996-2007 Andy Wardley.  All Rights Reserved.

This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

[%- END %]