$data->{show_columns} ? { map +($_ => $_), @{$data->{columns}} } : (),
@{$data->{data}}
);
+ my $column_count = scalar @{$data->{columns}};
[ 200, [ 'Content-type' => 'text/html' ], [
HTML::Tags::to_html_string(
<html>, <body>, "\n",
($data->{wrapper}||sub{@_})->(
'', <table>, "\n",
- @rows
- ? (map { my $el = $_;
- ' ', ($el->{key} eq '__error__') ? <tr class="error"> : <tr>,
- (map {
- <td>, $self->render_el($el, $_, $el->{$_}), </td>
- } @{$data->{columns}}),
- </tr>, "\n"
- } @rows)
+ (map { my $el = $_;
+ ' ', ($el->{key} eq '__error__') ? <tr class="error"> : <tr>,
+ (map {
+ <td>, $self->render_el($el, $_, $el->{$_}), </td>
+ } @{$data->{columns}}),
+ </tr>, "\n"
+ } @rows),
+ @{$data->{data}}
+ ? ()
: (<tr class="no-rows">,
- <td>, 'No entries in this data structure', </td>,
+ <td colspan="$column_count">,
+ 'No entries in this data structure',
+ </td>,
</tr>),
'', </table>, "\n",
),