template::param handles empty array/hash refs better
authorChristopher Hall <chris.hall@catalyst.net.nz>
Fri, 4 Feb 2011 02:10:59 +0000 (15:10 +1300)
committerChristopher Hall <chris.hall@catalyst.net.nz>
Fri, 4 Feb 2011 02:10:59 +0000 (15:10 +1300)
C4/Templates.pm

index 9a07d95..91b57fb 100644 (file)
@@ -109,6 +109,8 @@ sub param{
        my $key = shift;
        my $val = shift;
         utf8::encode($val) if utf8::is_utf8($val);
+        if( ref($val) eq 'ARRAY' && ! scalar @$val ){ $val = undef; }
+        elsif( ref($val) eq 'HASH' && ! scalar %$val ){ $val = undef; }
        $self->{VARS}->{$key} = $val;
     }
 }