: | $DIRECTIVES | ||
: | new(), init(), template_handler(), number(), literal(), quoted(), variable(), assign(), setlist(), qwlist(), list(), hash(), args() |
use Template::Compiler; my $compiler = Template::Compiler->new(); print $compiler->number($n); print $compiler->literal($text); print $compiler->variable(\@varnodes); print $compiler->assign(\@varnodes, $value); . . .
The compiler's role is to generate Perl code in response to event raised by the Template::Parser as it identifies text and directives in the source template.
The handler maintains a list of callbacks which have been registered to parse various directives. If a directive begins with a keyword that has a corresponding handler then the handler is called to parse the directive.
use Template::Compiler; $Template::Compiler::DIRECTIVES->{ INCLUDE } = \&my_include_parser;
new( \%vars )
Constructor method implemented by Template::Base.
use Template::Compiler; my $compiler = Template::Compiler->new({ DIRECTIVES => { INCLUDE => \&my_include_parser, }, });
init( \%config )
Initialiser method called by base class new() constructor method.
template_handler( \%config )
Create a new Template::Parser::Handler object
to handle the parsing of a template block.
my $handler = $compiler->template_handler();
number( $n )
Generate Perl code to represent a number. Returns $n
intact.
literal( $text )
Generate Perl code to represent a single quoted literal string.
quoted( \@items )
Generate Perl code to represent a double quoted literal string
from a list of items containing plain text and interpolated
variable references.
variable( \@varnodes )
Generate Perl code to fetch a variable from the
stash.
assign( \@varnodes, $value )
Generate Perl code to assign a variable value to the
stash.
setlist( \@assignments )
Generate Perl code to perform a list of assignments.
qwlist( \@items )
Generate Perl code to represent a quoted list of items.
list( \@items )
Generate Perl code to represent a list reference.
hash( \@items )
Generate Perl code to represent a hash reference.
args( \@items )
Generate Perl code to represent an argument list.