Add truncations to limit table widths.

This commit is contained in:
barnold 2022-09-26 09:03:20 +01:00
parent 07fdc53c95
commit 646d0c4084
3 changed files with 14 additions and 3 deletions

View File

@ -52,6 +52,17 @@ sub add_my_helpers ($self) {
$self->session('rows_per_page') // $self->default_rpp;
}
);
$self->helper(
trct => sub ($self, $str, $len) {
do {
if (length($str) <= $len) {
$str;
} else {
substr($str, 0, $len - 1) . '…';
}
};
}
);
return;
}

View File

@ -12,7 +12,7 @@ Books by <strong><%= $author->name %></strong>
</tr>
% for my $book ($book_page->all) {
<tr>
<td><%= $book->title %></td>
<td><%= trct($book->title, 100) %></td>
</tr>
% }
</table>

View File

@ -20,9 +20,9 @@
</tr>
% for my $book ($book_page->all) {
<tr>
<td><%= $book->title %></td>
<td><%= trct($book->title, 50) %></td>
<td>
<%= link_to($book->author->name => 'author' =>
<%= link_to(trct($book->author->name, 40) => 'author' =>
{ id => $book->author->id, page_number => 1 }) %>
</td>
</tr>