Corrent template description in Macro/AdminBar.
Added POD for two macros. Internationalized the If error message.
This commit is contained in:
parent
b621f3f605
commit
01816cd806
4 changed files with 65 additions and 5 deletions
|
|
@ -12,8 +12,37 @@ package WebGUI::Macro::If;
|
|||
|
||||
|
||||
use strict;
|
||||
use WebGUI::International;
|
||||
use Safe;
|
||||
|
||||
=head1 NAME
|
||||
|
||||
Package WebGUI::Macro::If
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
A macro for implementing a simple conditional.
|
||||
|
||||
=head2 process ( expression, trueResult, falseResult )
|
||||
|
||||
Returns trueResult if expression is true, falseResult if the expression
|
||||
is false and an error message if there was a problem evaluating the
|
||||
expression.
|
||||
|
||||
=head3 expression
|
||||
|
||||
A perl expression that will be evaulated in a Safe compartment.
|
||||
|
||||
=head3 trueResult
|
||||
|
||||
Text that will be returned if the expression is true.
|
||||
|
||||
=head3 falseResult
|
||||
|
||||
Text that will be returned if the expression is false.
|
||||
|
||||
=cut
|
||||
|
||||
sub process {
|
||||
my ($expression, $true, $false) = @_;
|
||||
my $output = $false;
|
||||
|
|
@ -22,8 +51,8 @@ sub process {
|
|||
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 ($@);
|
||||
return sprintf(WebGUI::International::get('eval error', 'Macro_If'),
|
||||
$@,$expression,$true,$false) if ($@);
|
||||
|
||||
$output = $true if ($return);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue