Konstrukt::Parser - Parser for the tag syntax
#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);
Parses a given file against special (e.g. <&...&>) tags.
#all tag names will be lowercased parser/lowercase_tags 1 parser/tag_start < parser/tag_end > parser/comment_start <!-- parser/comment_end -->
Constructor of this class
Initialization of this class
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:
Currently only used by the template plugin.
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:
Should look like:
$actions = { '&' => $Konstrukt::TagHandler::Plugin, ... }
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:
Should look like:
$actions = { '&' => $Konstrukt::TagHandler::Plugin, ... }
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:
Only used internally by "prepare" and "execute". Will merge the result returned by a plugin into the current position of the tree.
Parameters:
Only used internally by "prepare". Will recursively merge neighbouring plaintext or comment nodes of the same type.
Parameters:
Accepts a tag-string (e.g. template src="blah.template"
) and returns the parsed tag as an hashreference.
Parameters:
The parsed tag as an hashreference. Example for template src="blah.template" /
$tag = { type => 'template', attributes => { src => 'blah.template' }, singleclosing => 1 }
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.