[%# # 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 = 'Modules' page = 'Parser' %] [% WRAPPER toc; PROCESS tocitem title ="SYNOPSIS" subs = []; PROCESS tocitem title ="DESCRIPTION" subs = []; PROCESS tocitem title ="PUBLIC METHODS" subs = [ "new(\\%params)", "parse(\$text)" ]; PROCESS tocitem title ="AUTHOR" subs = []; PROCESS tocitem title ="VERSION" subs = []; PROCESS tocitem title ="COPYRIGHT" subs = []; PROCESS tocitem title ="SEE ALSO" subs = []; END %] [% WRAPPER section title="SYNOPSIS" -%]
    use Template::Parser;
    $parser   = Template::Parser->new(\%config);
    $template = $parser->parse($text)
        || die $parser->error(), "\n";
[%- END %] [% WRAPPER section title="DESCRIPTION" -%]

The Template::Parser module implements a LALR(1) parser and associated methods for parsing template documents into Perl code.

[%- END %] [% WRAPPER section title="PUBLIC METHODS" -%][% WRAPPER subsection title = "new(\\%params)" -%]

The new() constructor creates and returns a reference to a new Template::Parser object. A reference to a hash may be supplied as a parameter to provide configuration values. These may include:

[%- END %] [% WRAPPER subsection title = "parse(\$text)" -%]

The parse() method parses the text passed in the first parameter and returns a reference to a hash array of data defining the compiled representation of the template text, suitable for passing to the Template::Document new() constructor method. On error, undef is returned.


    $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 BLOCKs defined within in the template, and a METADATA item containing a reference to a hash array of metadata values defined in META tags.

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

Andy Wardley <abw@wardley.org>

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

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

2.89, distributed as part of the 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.

The original 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.
[%- END %] [% WRAPPER section title="SEE ALSO" -%]

[% ttlink('Template', 'Template') -%], [% ttlink('Template::Grammar', 'Template::Grammar') -%], [% ttlink('Template::Directive', 'Template::Directive') -%]

[%- END %]