Konstrukt::Plugin::embperl - Plugin for embedded Perl code
<& embperl &>print "hi!"<& / &>
With this plugin you may embed Perl code into the source code of an Konstrukt-webpage.
Those variables will be available to your code: $Konstrukt::Handler, $Konstrukt::Settings, $Konstrukt::Lib, $Konstrukt::Debug, $Konstrukt::File, $template_values.
The variable $template_values contains the template values passed to the file, which contains the embperl tag. It can be used to produce output for these values. The structure of this data will look like described in "node" in Konstrukt::Plugin::template. The values may be scalars (strings) or Konstrukt::Parser::Nodes. You should not modify this data!
Note that it would be wise in most cases to enclose the perl code in a comment to prevent parsing of the perl code by the Konstrukt-parser:
<& embperl &> #<-- sub one { return 1; } if (0<&one()) { print "hi!"; } #--> <& / &>
Otherwise 0<&one()
would lead into incorrect parsing. For more general information about plugins take a look at Konstrukt::Plugin.
You may configure the embperl plugin to parse the printed output for new tags:
#per default the output won't be parsed again embperl/parse_output_for_tags 0
Initialization. Will only be used internally.
The executed perl code may generate plaintext that will be parsed to new tag nodes.
If you plan to do it (although it is better to directly push the according tag nodes), you have to set the setting embperl/parse_output_for_tags to 1.
Yes, this plugin will very likely generate new tags.
We cannot prepare anything as the perl code generally will be completely dynamic.
All the work is done in the execute step. The result of print
-statements will be put into the page at the position of the embperl-tag.
Accepts the printredirector_print
-event and adds a plaintext node
The copyrights of this file are property of Thomas Wittek, tw@zentrifuge.biz
You may not alter or sell this piece of code without my permission.