Added the RootTab, RandomSnippet, RandomImage, CanEditText, If, Spacer, SpecificDropMenu, TopDropMenu, LastModified, PreviousDropMenu, and SI (scaled image) macros.
This commit is contained in:
parent
ff6a6e45ea
commit
6d234e929d
15 changed files with 564 additions and 6 deletions
35
lib/WebGUI/Macro/If.pm
Normal file
35
lib/WebGUI/Macro/If.pm
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
package WebGUI::Macro::If;
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
# WebGUI is Copyright 2001-2003 Plain Black Software.
|
||||
#-------------------------------------------------------------------
|
||||
# Please read the legal notices (docs/legal.txt) and the license
|
||||
# (docs/license.txt) that came with this distribution before using
|
||||
# this software.
|
||||
#-------------------------------------------------------------------
|
||||
# http://www.plainblack.com info@plainblack.com
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
|
||||
use strict;
|
||||
use Safe;
|
||||
use WebGUI::Macro;
|
||||
|
||||
sub process {
|
||||
my ($expression, $true, $false) = WebGUI::Macro::getParams(shift);
|
||||
my $output = $false;
|
||||
|
||||
# Workaround to "Safely" eval $expression
|
||||
my $compartment = new Safe;
|
||||
my $return = $compartment->reval($expression);
|
||||
|
||||
return "<p><b>If Macro failed:</b> $@ <p>Expression: $expression
|
||||
<br>Display if true: $true<br>Display if false: $false" if ($@);
|
||||
|
||||
$output = $true if ($return);
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue