add a marker and a notice if the table did not contain any rows
Robert 'phaylon' Sedlacek [Wed, 20 Jun 2012 19:45:27 +0000 (19:45 +0000)]
br.pl

diff --git a/br.pl b/br.pl
index 590d940..f900028 100644 (file)
--- a/br.pl
+++ b/br.pl
@@ -195,13 +195,17 @@ sub render_table {
       <html>, <body>, "\n",
       ($data->{wrapper}||sub{@_})->(
         '', <table>, "\n",
-          (map { my $el = $_;
-            '  ', ($el->{key} eq '__error__') ? <tr class="error"> : <tr>,
-              (map {
-                <td>, $self->render_el($el, $_, $el->{$_}), </td>
-              } @{$data->{columns}}),
-            </tr>, "\n"
-          } @rows),
+          @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)
+          : (<tr class="no-rows">,
+              <td>, 'No entries in this data structure', </td>,
+            </tr>),
         '', </table>, "\n",
       ),
       </body>, </html>, "\n",