Add truncations to limit table widths.
This commit is contained in:
parent
07fdc53c95
commit
646d0c4084
11
lib/MyApp.pm
11
lib/MyApp.pm
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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>
|
||||
|
|
Loading…
Reference in New Issue