Mojolicious::Plugin::Notifications::HTML - Event Notifications using HTML
# Register the engine plugin Notifications => { HTML => 1 }; # In the template %= notifications 'html'
This plugin is a simple notification engine for HTML.
If it does not suit your needs, you can easily write your own engine.
See the base notify helper.
$c->notify(warn => 'wrong'); $c->notify(success => 'right'); %= notifications 'html'; # <div class="notify notify-warn">wrong</div> # <div class="notify notify-success">right</div>
Will render each notification using notify_html.
use Mojolicious::Plugin::Notifications::HTML qw/notify_html/; notify_html(warn => 'This is a warning') # <div class="notify notify-warn">This is a warning</div> notify_html(announce => { ok => 'http://example.com/ok', ok_label => 'Okay!' # }, 'Confirm, please!') # <div class="notify notify-announce"> # Confirm, please! # <form action="http://example.com/ok" method="post"> # <button>Okay!</button> # </form> # </div>
Returns the formatted text in a <div /> element with the class notify and the class notify-$type, where $type is the notification type you passed. In case an ok parameter is passed, this will add a POST form for confirmation. In case an ok_label is passed, this will be the label for the confirmation button. In case a cancel parameter is passed, this will add a POST form for cancelation. In case a cancel_label is passed, this will be the label for the cancelation button.
<div />
notify
notify-$type
$type
ok
ok_label
cancel
cancel_label
If the first parameter is a Mojolicious::Controller object, the button will have a csrf_token parameter to validate.
This is meant to be used by other engines as a fallback.
Confirmation is EXPERIMENTAL!
https://github.com/Akron/Mojolicious-Plugin-Notifications
Copyright (C) 2014-2020, Nils Diewald.
This program is free software, you can redistribute it and/or modify it under the terms of the Artistic License version 2.0.
To install Mojolicious::Plugin::Notifications, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Mojolicious::Plugin::Notifications
CPAN shell
perl -MCPAN -e shell install Mojolicious::Plugin::Notifications
For more information on module installation, please visit the detailed CPAN module installation guide.