first commit
This commit is contained in:
30
xxx/app/lib/XxxApp/Helpers.pm
Normal file
30
xxx/app/lib/XxxApp/Helpers.pm
Normal file
@@ -0,0 +1,30 @@
|
||||
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;
|
||||
Reference in New Issue
Block a user