The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

Mojolicious::Plugin::NamedHelpers - Mojolicious Plugin

SYNOPSIS

  # Mojolicious
  $self->plugin('NamedHelpers');
  $self->named_helper( my_little_helper => sub { ... } );

  # Mojolicious::Lite
  plugin 'NamedHelpers';

  # Mojolicious::Lite - with custom namespace
  plugin 'NamedHelpers' => { namespace => 'My::App::Helpers' };

DESCRIPTION

Mojolicious::Plugin::NamedHelpers is a Mojolicious plugin that sets a fully qualified name to anonymous helper subs using a tiny wrapper upon helper creation. Without this plugin those subs will be named __ANON__, but now they will be named after the helper.

By default the namespace will be the same as the app, but this can be overridden if desired.

The author's use-case is for providing more context in JSON-based application logs, where all helpers would identify themselves as __ANON__.

HELPERS

named_helper

This plugin provides a new helper called "named_helper".

By registering your helpers with "named_helper" the name of the sub will be set equal to the name of the helper.

AUTHOR

Vidar Tyldum <vidar@tyldum.com>

CREDITS

This module is written by Vidar Tyldum, but with crucial help from the #mojo IRC channel on irc.perl.org.

COPYRIGHT AND LICENSE

This software is Copyright (c) 2018 by Vidar Tyldum.

This is free software, licensed under:

  The Artistic License 2.0 (GPL Compatible)

SEE ALSO

Sub::Util, Mojolicious, Mojolicious::Guides, http://mojolicious.org.