<<

NAME

Konstrukt::Parser - Parser for the tag syntax

SYNOPSIS

        #this will be done in your top-level handler.
        use Konstrukt::Parser;
        
        #prepare run
        my $actions = { '&' => $Konstrukt::TagHandler::Plugin };
        my $prepared = $Konstrukt::Parser->prepare(\$some_input, $actions);
        
        #execute run
        my $executed = $Konstrukt::Parser->execute($prepared, $actions);

DESCRIPTION

Parses a given file against special (e.g. <&...&>) tags.

CONFIGURATION

        #all tag names will be lowercased
        parser/lowercase_tags 1
        parser/tag_start      <
        parser/tag_end        >
        parser/comment_start  <!--
        parser/comment_end    -->

METHODS

new

Constructor of this class

init

Initialization of this class

prepare

This sub will accept a scalarref or a node with some children.

Plaintext nodes will be parsed into tags and executed.

All plugins/tags that return static output on static input will be executed ($plugin->prepare()) and replaced by the returned static content.

Plugins/tags that generate dynamic content will stay in the tree to be executed in the "execute" run ($plugin->execute()).

Tag nodes will be prepare()'d recursively.

Parameters:

parse_and_prepare_tag

Will generate a final tag of the passed preliminary tag. The prepare method will be called on this tag.

Returns the new "parent" node, under which all new nodes will be collected.

Parameters:

prepare_tag

Will run the prepare method on a specified tag, if possible (i.e. if the tag could be finally parsed, an action is specified and the tag doesn't have dynamic children).

The result will be put into the tree instead of the prepared tag, if the tag returned a result.

Parameters:

execute

This sub takes a tree (usually the result of "prepare") and executes all plugins. Every plugin must return static content now as the result of the execution is the final result of the parsing process.

Parameters:

merge_plugin_results

Only used internally by "prepare" and "execute". Will merge the result returned by a plugin into the current position of the tree.

Parameters:

merge_similar_neighbours

Only used internally by "prepare". Will recursively merge neighbouring plaintext or comment nodes of the same type.

Parameters:

parse_tag

Accepts a tag-string (e.g. template src="blah.template") and returns the parsed tag as an hashreference.

Parameters:

Returns:

The parsed tag as an hashreference. Example for template src="blah.template" /

        $tag = {
                type => 'template',
                attributes => { src => 'blah.template' },
                singleclosing => 1
        }

AUTHOR

Copyright 2006 Thomas Wittek (mail at gedankenkonstrukt dot de). All rights reserved.

This document is free software. It is distributed under the same terms as Perl itself.

SEE ALSO

Konstrukt::Parser::Node, Konstrukt::TagHandler, Konstrukt

<<