The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Konstrukt::Plugin::perl - Embedding perl code in your pages/templates

SYNOPSIS

Usage:

        <& perl &>print "foo"<& / &>

Result:

        foo
        

DESCRIPTION

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 perl 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 some cases to enclose the perl code within a comment to prevent parsing of the perl code by the Konstrukt-parser:

        <& perl &>
                #<--
                sub one { return 1; }
                if (0<&one()) { print "hi!"; }
                #-->
        <& / &>

Otherwise 0<&one() would lead into incorrect parsing as <& would get recognized as a plugin tag start.

For more general information about plugins take a look at Konstrukt::Plugin.

CONFIGURATION

You may configure the perl plugin to parse the printed output for new tags:

        #per default the output won't be parsed again
        perl/parse_output_for_tags 0

METHODS

init

Initialization. Will only be used internally.

prepare_again

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 perl/parse_output_for_tags to 1.

execute_again

Yes, this plugin will very likely generate new tags.

prepare

We cannot prepare anything as the perl code generally will be completely dynamic.

execute

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 perl-tag.

Accepts the printredirector_print-event and adds a plaintext node

Parameters:

  • @data - The data passed to the print function

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::Plugin, Konstrukt