use Template::Parser; $parser = Template::Parser->new(\%config); $template = $parser->parse($text) || die $parser->error(), "\n";
A reference to a hash may be supplied as a parameter to provide configuration values. See ``CONFIGURATION OPTIONS'' below for a summary of these options and Template::Manual::Config for full details.
my $parser = Template::Parser->new({ START_TAG => quotemeta('<+'), END_TAG => quotemeta('+>'), });
$data = $parser->parse($text) || die $parser->error();
The $data hash reference returned contains a "BLOCK" item containing the compiled Perl code for the template, a "DEFBLOCKS" item containing a reference to a hash array of sub-template "BLOCK"s defined within in the template, and a "METADATA" item containing a reference to a hash array of metadata values defined in "META" tags.
my $parser = Template::Parser->new({ START_TAG => quotemeta('<+'), END_TAG => quotemeta('+>'), });
my $parser = Template::Parser->new({ TAG_STYLE => 'star', # [* ... *] });
my $parser = Template::Parser-E<gt>new({ PRE_CHOMP => 1, POST_CHOMP => 1, });
my $parser = Template::Parser->new({ INTERPOLATE => 1, });
Variables should be prefixed by a "$" to identify them, using curly braces to explicitly scope the variable name where necessary.
Hello ${name}, The day today is ${day.today}.
# with ANYCASE set to 1 [% INCLUDE foobar %] # OK [% include foobar %] # OK [% include = 10 %] # ERROR, 'include' is a reserved word
use MyOrg::Template::Grammar; my $parser = Template::Parser->new({ GRAMMAR = MyOrg::Template::Grammar->new(); });
By default, an instance of the default Template::Grammar will be created and used automatically if a "GRAMMAR" item isn't specified.
use Template::Constants qw( :debug ); my $template = Template->new({ DEBUG => DEBUG_PARSER | DEBUG_DIRS, });
This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
The main parsing loop of the "Template::Parser" module was derived from a standalone parser generated by version 0.16 of the "Parse::Yapp" module. The following copyright notice appears in the "Parse::Yapp" documentation.
The Parse::Yapp module and its related modules and shell scripts are copyright (c) 1998 Francois Desarmenien, France. All rights reserved. You may use and distribute them under the terms of either the GNU General Public License or the Artistic License, as specified in the Perl README file.