This repository has been archived on 2023-08-16. You can view files and clone it, but cannot push or open issues or pull requests.
Foodloop-Server/lib/Pear/LocalLoop/Plugin/TemplateHelpers.pm

23 lines
467 B
Perl
Raw Permalink Normal View History

2017-09-28 15:39:03 +00:00
package Pear::LocalLoop::Plugin::TemplateHelpers;
use Mojo::Base 'Mojolicious::Plugin';
sub register {
2021-03-20 12:09:50 +00:00
my ( $plugin, $app, $conf ) = @_;
2017-09-28 15:39:03 +00:00
2021-03-20 12:09:50 +00:00
$app->helper(
truncate_text => sub {
my ( $c, $string, $length ) = @_;
if ( length $string < $length ) {
return $string;
}
else {
return substr( $string, 0, $length - 3 ) . '...';
}
}
);
2021-03-20 23:26:52 +00:00
2021-03-20 15:02:00 +00:00
return 1;
2017-09-28 15:39:03 +00:00
}
1;