File Coverage

blib/lib/Catalyst/Plugin/BootstrapAlert.pm
Criterion Covered Total %
statement 8 40 20.0
branch 0 4 0.0
condition 0 4 0.0
subroutine 3 13 23.0
pod 7 7 100.0
total 18 68 26.4


line stmt bran cond sub pod time code
1             package Catalyst::Plugin::BootstrapAlert;
2              
3 1     1   15048 use 5.006;
  1         5  
4              
5 1     1   8 use strict;
  1         4  
  1         32  
6 1     1   6 use warnings;
  1         6  
  1         458  
7              
8             =head1 NAME
9              
10             Catalyst::Plugin::BootstrapAlert - Replacement for Catalyst::Plugin::StatusMessage inline with Bootstrap alert names (success, info, warning, and danger).
11              
12             =head1 VERSION
13              
14             Version 0.40
15              
16             =cut
17              
18             our $VERSION = '0.40';
19              
20             $VERSION = eval $VERSION;
21              
22             =head1 SYNOPSIS
23              
24             Replacement for Catalyst::Plugin::StatusMessage using Bootstrap alert names (success, info, warning, and danger),
25             whilst also keeping C and C as aliases.
26              
27             In MyApp.pm:
28              
29             use Catalyst qr/
30             BootstrapAlert
31             /;
32              
33             In controller where you want to save a message for display on the next page:
34              
35             $c->response->redirect( "/?mid=" . $c->set_success_alert("It worked!") );
36              
37             Or, to save an danger message:
38              
39             $c->response->redirect( "/?mid=" . $c->set_error_msg("Error deleting widget") );
40              
41             Then, in the controller action that corresponds to the redirect above:
42              
43             sub list :Path {
44             my ($self, $c) = @_;
45             ...
46             $c->load_bootstrap_alerts;
47             ...
48             }
49              
50             This would mean simply changing C if using C.
51              
52             And, to display the output (here using L