X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FExcel%2FTemplate%2FContainer%2FConditional.pm;h=6b492d332b1c8c587fa222fc2a8855e10caba496;hb=HEAD;hp=1143a2ce6fe6cf9e02eef0aa06bf22707da8f936;hpb=dee1f2390b1d5808099f96e088a0d4bc1e0ce27a;p=p5sagit%2FExcel-Template.git diff --git a/lib/Excel/Template/Container/Conditional.pm b/lib/Excel/Template/Container/Conditional.pm index 1143a2c..6b492d3 100644 --- a/lib/Excel/Template/Container/Conditional.pm +++ b/lib/Excel/Template/Container/Conditional.pm @@ -17,7 +17,7 @@ my %isOp = ( (map { $_ => $_ } ( 'gt', 'lt', 'eq', 'ne', 'ge', 'le' )), ); -sub conditional_passes +sub _conditional_passes { my $self = shift; my ($context) = @_; @@ -26,8 +26,8 @@ sub conditional_passes return 0 unless $name =~ /\S/; my $val = $context->param($name); - $val = @{$val} while UNIVERSAL::isa($val, 'ARRAY'); - $val = ${$val} while UNIVERSAL::isa($val, 'SCALAR'); + $val = @{$val} while ref $val eq 'ARRAY'; + $val = ${$val} while ref $val eq 'SCALAR'; my $value = $context->get($self, 'VALUE'); if (defined $value) @@ -53,7 +53,7 @@ sub conditional_passes /^ge$/ && do { $res = ($val ge $value); last }; /^le$/ && do { $res = ($val le $value); last }; - die "Unknown operator in conditional resolve", $/; + die "Unknown operator '$op' in conditional resolve", $/; } return $res && 1; @@ -61,7 +61,7 @@ sub conditional_passes my $istrue = $val && 1; - my $is = uc $context->get($self, 'IS') || 'TRUE'; + my $is = uc($context->get($self, 'IS') || 'TRUE'); if ($is eq 'TRUE') { return 0 unless $istrue; @@ -82,30 +82,30 @@ sub render my $self = shift; my ($context) = @_; - return 1 unless $self->conditional_passes($context); + return 1 unless $self->_conditional_passes($context); return $self->iterate_over_children($context); } -sub max_of -{ - my $self = shift; - my ($context, $attr) = @_; - - return 0 unless $self->conditional_passes($context); - - return $self->SUPER::max_of($context, $attr); -} - -sub total_of -{ - my $self = shift; - my ($context, $attr) = @_; - - return 0 unless $self->conditional_passes($context); - - return $self->SUPER::total_of($context, $attr); -} +#sub max_of +#{ +# my $self = shift; +# my ($context, $attr) = @_; +# +# return 0 unless $self->_conditional_passes($context); +# +# return $self->SUPER::max_of($context, $attr); +#} +# +#sub total_of +#{ +# my $self = shift; +# my ($context, $attr) = @_; +# +# return 0 unless $self->_conditional_passes($context); +# +# return $self->SUPER::total_of($context, $attr); +#} 1; __END__ @@ -124,7 +124,7 @@ IF =head1 INHERITANCE -Excel::Template::Container +L =head1 ATTRIBUTES @@ -132,26 +132,23 @@ Excel::Template::Container =item * NAME -This is the name of the parameter to be testing. It is resolved like any other -parameter. +This is the name of the parameter to test. It is resolved like any other parameter name. (q.v. L for more info.) =item * VALUE -If VALUE is set, then a comparison operation is done. The value of NAME is -compared to VALUE using the value of OP. +If VALUE is set, then a comparison operation is done. The value of NAME is compared to VALUE using the value of OP. =item * OP -If VALUE is set, then this is checked. If it isn't present, then '==' (numeric -equality) is assumed. OP must be one of the numeric comparison operators or the -string comparison operators. All 6 of each kind is supported. +If VALUE is set, then this is checked. If it isn't present, then '==' (numeric equality) is assumed. OP must be one of Perl the numeric comparison operators or the string comparison operators. All 6 of each kind is supported. + +B: If you want to use < or <=, you must instead use < or <=. This is to make sure it will parse with L. You should not need to use > or >= instead of > and >=, respectively. =item * IS -If VALUE is not set, then IS is checked. IS is allowed to be either "TRUE" or -"FALSE". The boolean value of NAME is checked against IS. +If VALUE is not set, then IS is checked. IS is allowed to be either "TRUE" or "FALSE". The boolean value of NAME is checked against IS. -=back 4 +=back =head1 CHILDREN @@ -171,8 +168,7 @@ None ... Children here -In the above example, the children will be executed if the value of __ODD__ -(which is set by the LOOP node) is false. So, for all even iterations. +In the above example, the children will be executed if the value of __ODD__ (which is set by the L node) is false. So, for all even iterations. =head1 AUTHOR @@ -180,6 +176,6 @@ Rob Kinyon (rob.kinyon@gmail.com) =head1 SEE ALSO -LOOP +L, L =cut