--- /dev/null
+.\" Automatically generated by Pod::Man v1.37, Pod::Parser v1.3
+.\"
+.\" Standard preamble:
+.\" ========================================================================
+.de Sh \" Subsection heading
+.br
+.if t .Sp
+.ne 5
+.PP
+\fB\\$1\fR
+.PP
+..
+.de Sp \" Vertical space (when we can't use .PP)
+.if t .sp .5v
+.if n .sp
+..
+.de Vb \" Begin verbatim text
+.ft CW
+.nf
+.ne \\$1
+..
+.de Ve \" End verbatim text
+.ft R
+.fi
+..
+.\" Set up some character translations and predefined strings. \*(-- will
+.\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left
+.\" double quote, and \*(R" will give a right double quote. | will give a
+.\" real vertical bar. \*(C+ will give a nicer C++. Capital omega is used to
+.\" do unbreakable dashes and therefore won't be available. \*(C` and \*(C'
+.\" expand to `' in nroff, nothing in troff, for use with C<>.
+.tr \(*W-|\(bv\*(Tr
+.ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'
+.ie n \{\
+. ds -- \(*W-
+. ds PI pi
+. if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch
+. if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch
+. ds L" ""
+. ds R" ""
+. ds C` ""
+. ds C' ""
+'br\}
+.el\{\
+. ds -- \|\(em\|
+. ds PI \(*p
+. ds L" ``
+. ds R" ''
+'br\}
+.\"
+.\" If the F register is turned on, we'll generate index entries on stderr for
+.\" titles (.TH), headers (.SH), subsections (.Sh), items (.Ip), and index
+.\" entries marked with X<> in POD. Of course, you'll have to process the
+.\" output yourself in some meaningful fashion.
+.if \nF \{\
+. de IX
+. tm Index:\\$1\t\\n%\t"\\$2"
+..
+. nr % 0
+. rr F
+.\}
+.\"
+.\" For nroff, turn off justification. Always turn off hyphenation; it makes
+.\" way too many mistakes in technical documents.
+.hy 0
+.if n .na
+.\"
+.\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2).
+.\" Fear. Run. Save yourself. No user-serviceable parts.
+. \" fudge factors for nroff and troff
+.if n \{\
+. ds #H 0
+. ds #V .8m
+. ds #F .3m
+. ds #[ \f1
+. ds #] \fP
+.\}
+.if t \{\
+. ds #H ((1u-(\\\\n(.fu%2u))*.13m)
+. ds #V .6m
+. ds #F 0
+. ds #[ \&
+. ds #] \&
+.\}
+. \" simple accents for nroff and troff
+.if n \{\
+. ds ' \&
+. ds ` \&
+. ds ^ \&
+. ds , \&
+. ds ~ ~
+. ds /
+.\}
+.if t \{\
+. ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u"
+. ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u'
+. ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u'
+. ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u'
+. ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u'
+. ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u'
+.\}
+. \" troff and (daisy-wheel) nroff accents
+.ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V'
+.ds 8 \h'\*(#H'\(*b\h'-\*(#H'
+.ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#]
+.ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H'
+.ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u'
+.ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#]
+.ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#]
+.ds ae a\h'-(\w'a'u*4/10)'e
+.ds Ae A\h'-(\w'A'u*4/10)'E
+. \" corrections for vroff
+.if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u'
+.if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u'
+. \" for low resolution devices (crt and lpr)
+.if \n(.H>23 .if \n(.V>19 \
+\{\
+. ds : e
+. ds 8 ss
+. ds o a
+. ds d- d\h'-1'\(ga
+. ds D- D\h'-1'\(hy
+. ds th \o'bp'
+. ds Th \o'LP'
+. ds ae ae
+. ds Ae AE
+.\}
+.rm #[ #] #H #V #F C
+.\" ========================================================================
+.\"
+.IX Title "Template::Document 3"
+.TH Template::Document 3 "2009-06-17" "perl v5.8.7" "User Contributed Perl Documentation"
+.SH "NAME"
+Template::Document \- Compiled template document object
+.SH "SYNOPSIS"
+.IX Header "SYNOPSIS"
+.Vb 1
+\& use Template::Document;
+.Ve
+.PP
+.Vb 11
+\& $doc = Template::Document\->new({
+\& BLOCK => sub { # some perl code; return $some_text },
+\& DEFBLOCKS => {
+\& header => sub { # more perl code; return $some_text },
+\& footer => sub { # blah blah blah; return $some_text },
+\& },
+\& METADATA => {
+\& author => 'Andy Wardley',
+\& version => 3.14,
+\& }
+\& }) || die $Template::Document::ERROR;
+.Ve
+.PP
+.Vb 1
+\& print $doc\->process($context);
+.Ve
+.SH "DESCRIPTION"
+.IX Header "DESCRIPTION"
+This module defines an object class whose instances represent compiled
+template documents. The Template::Parser module creates a
+\&\f(CW\*(C`Template::Document\*(C'\fR instance to encapsulate a template as it is compiled
+into Perl code.
+.PP
+The constructor method, \fInew()\fR, expects a reference to a hash array
+containing the \f(CW\*(C`BLOCK\*(C'\fR, \f(CW\*(C`DEFBLOCKS\*(C'\fR and \f(CW\*(C`METADATA\*(C'\fR items.
+.PP
+The \f(CW\*(C`BLOCK\*(C'\fR item should contain a reference to a Perl subroutine or a textual
+representation of Perl code, as generated by the Template::Parser module.
+This is then evaluated into a subroutine reference using \f(CW\*(C`eval()\*(C'\fR.
+.PP
+The \f(CW\*(C`DEFLOCKS\*(C'\fR item should reference a hash array containing further named
+\&\f(CW\*(C`BLOCK\*(C'\fRs which may be defined in the template. The keys represent \f(CW\*(C`BLOCK\*(C'\fR
+names and the values should be subroutine references or text strings of Perl
+code as per the main \f(CW\*(C`BLOCK\*(C'\fR item.
+.PP
+The \f(CW\*(C`METADATA\*(C'\fR item should reference a hash array of metadata items relevant
+to the document.
+.PP
+The \fIprocess()\fR method can then be called on the instantiated
+\&\f(CW\*(C`Template::Document\*(C'\fR object, passing a reference to a Template::Context
+object as the first parameter. This will install any locally defined blocks
+(\f(CW\*(C`DEFBLOCKS\*(C'\fR) in the \f(CW\*(C`BLOCKS\*(C'\fR cache in the context (via a call to
+\&\fIvisit()\fR) so that they may be subsequently
+resolved by the context. The main \f(CW\*(C`BLOCK\*(C'\fR subroutine is then executed,
+passing the context reference on as a parameter. The text returned from the
+template subroutine is then returned by the \fIprocess()\fR method, after calling
+the context \fIleave()\fR method to permit cleanup and
+de-registration of named \f(CW\*(C`BLOCKS\*(C'\fR previously installed.
+.PP
+An \f(CW\*(C`AUTOLOAD\*(C'\fR method provides access to the \f(CW\*(C`METADATA\*(C'\fR items for the
+document. The Template::Service module installs a reference to the main
+\&\f(CW\*(C`Template::Document\*(C'\fR object in the stash as the \f(CW\*(C`template\*(C'\fR variable. This allows
+metadata items to be accessed from within templates, including \f(CW\*(C`PRE_PROCESS\*(C'\fR
+templates.
+.PP
+header:
+.PP
+.Vb 5
+\& <html>
+\& <head>
+\& <title>[% template.title %]
+\& </head>
+\& ...
+.Ve
+.PP
+\&\f(CW\*(C`Template::Document\*(C'\fR objects are usually created by the Template::Parser
+but can be manually instantiated or sub-classed to provide custom
+template components.
+.SH "METHODS"
+.IX Header "METHODS"
+.Sh "new(\e%config)"
+.IX Subsection "new(%config)"
+Constructor method which accept a reference to a hash array containing the
+structure as shown in this example:
+.PP
+.Vb 11
+\& $doc = Template::Document\->new({
+\& BLOCK => sub { # some perl code; return $some_text },
+\& DEFBLOCKS => {
+\& header => sub { # more perl code; return $some_text },
+\& footer => sub { # blah blah blah; return $some_text },
+\& },
+\& METADATA => {
+\& author => 'Andy Wardley',
+\& version => 3.14,
+\& }
+\& }) || die $Template::Document::ERROR;
+.Ve
+.PP
+\&\f(CW\*(C`BLOCK\*(C'\fR and \f(CW\*(C`DEFBLOCKS\*(C'\fR items may be expressed as references to Perl subroutines
+or as text strings containing Perl subroutine definitions, as is generated
+by the Template::Parser module. These are evaluated into subroutine references
+using \f(CW\*(C`eval()\*(C'\fR.
+.PP
+Returns a new \f(CW\*(C`Template::Document\*(C'\fR object or \f(CW\*(C`undef\*(C'\fR on error. The
+\&\fIerror()\fR class method can be called, or the \f(CW$ERROR\fR
+package variable inspected to retrieve the relevant error message.
+.Sh "process($context)"
+.IX Subsection "process($context)"
+Main processing routine for the compiled template document. A reference to a
+Template::Context object should be passed as the first parameter. The
+method installs any locally defined blocks via a call to the context
+\&\fIvisit()\fR method, processes its own template,
+(passing the context reference as a parameter) and then calls
+\&\fIleave()\fR in the context to allow cleanup.
+.PP
+.Vb 1
+\& print $doc\->process($context);
+.Ve
+.PP
+Returns a text string representing the generated output for the template.
+Errors are thrown via \f(CW\*(C`die()\*(C'\fR.
+.Sh "\fIblock()\fP"
+.IX Subsection "block()"
+Returns a reference to the main \f(CW\*(C`BLOCK\*(C'\fR subroutine.
+.Sh "\fIblocks()\fP"
+.IX Subsection "blocks()"
+Returns a reference to the hash array of named \f(CW\*(C`DEFBLOCKS\*(C'\fR subroutines.
+.Sh "\s-1AUTOLOAD\s0"
+.IX Subsection "AUTOLOAD"
+An autoload method returns \f(CW\*(C`METADATA\*(C'\fR items.
+.PP
+.Vb 1
+\& print $doc\->author();
+.Ve
+.SH "PACKAGE SUB-ROUTINES"
+.IX Header "PACKAGE SUB-ROUTINES"
+.Sh "write_perl_file(\e%config)"
+.IX Subsection "write_perl_file(%config)"
+This package subroutine is provided to effect persistence of compiled
+templates. If the \f(CW\*(C`COMPILE_EXT\*(C'\fR option (to indicate a file extension
+for saving compiled templates) then the Template::Parser module calls
+this subroutine before calling the \fInew()\fR constructor. At this stage,
+the parser has a representation of the template as text strings
+containing Perl code. We can write that to a file, enclosed in a
+small wrapper which will allow us to susequently \f(CW\*(C`require()\*(C'\fR the file
+and have Perl parse and compile it into a \f(CW\*(C`Template::Document\*(C'\fR. Thus we
+have persistence of compiled templates.
+.SH "AUTHOR"
+.IX Header "AUTHOR"
+Andy Wardley <abw@wardley.org> <http://wardley.org/>
+.SH "COPYRIGHT"
+.IX Header "COPYRIGHT"
+Copyright (C) 1996\-2007 Andy Wardley. All Rights Reserved.
+.PP
+This module is free software; you can redistribute it and/or
+modify it under the same terms as Perl itself.
+.SH "SEE ALSO"
+.IX Header "SEE ALSO"
+Template, Template::Parser