31 lines
611 B
Perl
31 lines
611 B
Perl
package XxxApp::Helpers;
|
|
use Mojo::Base 'Mojolicious::Plugin';
|
|
|
|
sub register {
|
|
my ($self, $app, $args) = @_;
|
|
|
|
$app->helper('trim' => \&_trim);
|
|
$app->helper('debuglog' => \&_debuglog);
|
|
|
|
$app->log->info(sprintf('REGISTERED: %s', __PACKAGE__)) if !!$args->{verbose};
|
|
return;
|
|
}
|
|
|
|
# Führende und nachfolgende Leerzeichen entfernen
|
|
sub _trim {
|
|
my ($c, $str) = @_;
|
|
$str =~ s/^\s+|\s+$//g;
|
|
return $str;
|
|
};
|
|
|
|
sub _debuglog {
|
|
my ($c, $info) = @_;
|
|
if ( $c->config->{logging}->{level} =~ /trace|debug/ ) {
|
|
$c->log->debug($info);
|
|
}
|
|
|
|
return 1;
|
|
}
|
|
|
|
1;
|