NAME
Konstrukt::Plugin::if - Conditional blocks
SYNOPSIS
Usage:
<!-- will put out "elsif1" -->
<& if condition="0" &>
<$ then $>then<$ / $>
<$ elsif condition="1" $>elsif1<$ / $>
<$ elsif condition="1" $>elsif2<$ / $>
<$ else $>else<$ / $>
<& / &>
<!-- shortcut, when only using "then" and no elsif or else -->
<!-- will put out "The condition is true!" -->
<& if condition="2 > 1" &>
The condition is true!
<& / &>
Result:
<!-- will put out "elsif1" -->
elsif1
<!-- shortcut, when only using "then" and no elsif or else -->
<!-- will put out "The condition is true!" -->
The condition is true!
DESCRIPTION
Will put out the appropriate content for the conditions. Will delete the block, if no condition matches and no else block is supplied.
The condition will be eval
'ed. So if you only want to check if a value is true, you might want to encapsulate it in quotes, so that it won't be interpreted as perl code:
<& if condition="'some value'" &>true<& / &>
Of course this will lead into problems, when the data between the quotes contains qoutes itself. So you really should be careful with the values that are put into the condition, as they will be executed as perl code. You'd better never pass conditions, that contain any strings entered by a user.
METHODS
prepare
Everything will be done here as we can already parse for <$ then $> and so on in the prepare run.
If the if-tag is preliminary (i.e. when there is a tag inside the tag) this method will actually be called in the execute run.
Parameters:
$tag - Reference to the tag (and its children) that shall be handled.
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.