--- lib/PXElator/html.pm 2009/08/06 18:09:30 161 +++ lib/PXElator/html.pm 2009/08/27 19:58:18 315 @@ -1,12 +1,27 @@ package html; +use Data::Dump qw/dump/; + sub table { my $cols = shift; + my $th; + + if ( $cols < 0 ) { + $cols = abs($cols); + $th .= qq|| . shift(@_) . qq|| foreach ( 1 .. $cols ); + $th .= qq|\n|; + } + my @td = map { "$_" } @_; - my $html = qq{\n}; + my $html = qq{
\n$th}; + my $row = 0; + foreach ( 0 .. $#td ) { $html .= $td[$_]; - $html .= qq{\n} if $_ % $cols == 1; + if ( ( $_ + 1 ) % $cols == 0 ) { + $zebra = $row++ % 2 == 0 ? qq{ style="background: #eee"} : ''; + $html .= qq{\n}; + }; } $html .= qq{\n
}; } @@ -24,12 +39,13 @@ sub tt { - qq|| . join(' ', @_) . qq||; + qq|| . join(' ', @_) . qq|| if @_; } sub select { my $name = shift; my $selected_option = shift; + unshift @_, '' unless $selected_option; return join("\n" , qq|