: | new(), init(), clone(), directives(), content(), text(), directive() |
use Template::Parser::Handler; my $handler = Template::Parser::Handler->new();
Objects of this class are created to handle the parsing of a block
of template code. The handler receives events from the parser to indicate
text()
and directive()
events.
The handler delegates parsing of directives to the
DIRECTIVES
handlers defined for them. Otherwise,
a directive is treated as a bare GET or SET and handled via
the parser parse_statement()
method.
The handler collects the resultant Perl code generated by the
directive parsers and/or the compiler module and makes this
available via the content()
method.
new( \%vars )
Constructor method implemented by Template::Base.
use Template::Parser::Handler; my $handler = Template::Parser::Handler->new({ DIRECTIVES => { INCLUDE => \&my_include_parser, }, });
init( \%config )
Initialiser method called by base class new() constructor method.
clone( \%config )
clone( key => value, key => value, ... )
Create a clone of the current handler with the existing set of
defined DIRECTIVES supplemented (and possibly masked by) any
new directives passed as arguments.
$handler = $handler->clone( DIRECTIVES => { INCLUDE => \&my_new_include_parser_handler, });
directives()
Returns a reference to the current DIRECTIVES hash array.
$directives = $handler->directives();
content()
Returns a reference to the current CONTENT list.
$content = $handler->content();
text( $text )
Add a text item to the internal CONTENT list.
$handler->text('The cat sat on the mat');
directive( $text )
Accept a directive text, parse it and add the generated compiled output
to the internal CONTENT list.
$handler->directive('INCLUDE foobar');