File Coverage

blib/lib/Mojolicious/Plugin/BootstrapHelpers.pm
Criterion Covered Total %
statement 55 59 93.2
branch 6 12 50.0
condition 3 14 21.4
subroutine 8 8 100.0
pod 1 2 50.0
total 73 95 76.8


line stmt bran cond sub pod time code
1 14     14   10199 use 5.20.0;
  14         79  
2 14     14   67 use warnings;
  14         25  
  14         743  
3              
4             package Mojolicious::Plugin::BootstrapHelpers;
5              
6             # ABSTRACT: Type less bootstrap
7             our $AUTHORITY = 'cpan:CSSON'; # AUTHORITY
8             our $VERSION = '0.0206';
9              
10 14     14   74 use Mojo::Base 'Mojolicious::Plugin';
  14         23  
  14         91  
11 14     14   9025 use Mojolicious::Plugin::BootstrapHelpers::Helpers;
  14         45  
  14         488  
12 14     14   86 use experimental qw/postderef signatures/;
  14         28  
  14         65  
13              
14 14     14 1 691 sub register($self, $app, $args) {
  14         33  
  14         26  
  14         25  
  14         23  
15              
16 14 50       56 if(exists $args->{'short_strappings_prefix'}) {
17 0         0 $app->log->debug("'short_strappings_prefix' is deprecated. Use 'shortcut_prefix' instead");
18 0   0     0 $args->{'shortcut_prefix'} //= $args->{'short_strappings_prefix'};
19             }
20 14 50       40 if(exists $args->{'init_short_strappings'}) {
21 0         0 $app->log->debug("'init_short_strappings' is deprecated. Use 'init_shortcuts' instead");
22 0   0     0 $args->{'init_shortcuts'} //= $args->{'init_short_strappings'};
23             }
24 14         51 my $tp = setup_prefix($args->{'tag_prefix'});
25 14         47 my $ssp = setup_prefix($args->{'shortcut_prefix'});
26 14   50     88 my $init_shortcuts = $args->{'init_shortcuts'} //= 1;
27              
28 14         155 $app->helper($tp.'bootstrap' => \&Mojolicious::Plugin::BootstrapHelpers::Helpers::bootstraps_bootstraps);
29 14         1938 $app->helper($tp.'table' => \&Mojolicious::Plugin::BootstrapHelpers::Helpers::bootstrap_table);
30 14         1004 $app->helper($tp.'panel' => \&Mojolicious::Plugin::BootstrapHelpers::Helpers::bootstrap_panel);
31 14         954 $app->helper($tp.'formgroup' => \&Mojolicious::Plugin::BootstrapHelpers::Helpers::bootstrap_formgroup);
32 14         964 $app->helper($tp.'button' => \&Mojolicious::Plugin::BootstrapHelpers::Helpers::bootstrap_button);
33 14         963 $app->helper($tp.'submit_button' => \&Mojolicious::Plugin::BootstrapHelpers::Helpers::bootstrap_submit);
34 14         553 $app->helper($tp.'badge' => \&Mojolicious::Plugin::BootstrapHelpers::Helpers::bootstrap_badge);
35 14         976 $app->helper($tp.'context_menu' => \&Mojolicious::Plugin::BootstrapHelpers::Helpers::bootstrap_context_menu);
36 14         965 $app->helper($tp.'dropdown' => \&Mojolicious::Plugin::BootstrapHelpers::Helpers::bootstrap_dropdown);
37 14         935 $app->helper($tp.'buttongroup' => \&Mojolicious::Plugin::BootstrapHelpers::Helpers::bootstrap_buttongroup);
38 14         994 $app->helper($tp.'toolbar' => \&Mojolicious::Plugin::BootstrapHelpers::Helpers::bootstrap_toolbar);
39 14         939 $app->helper($tp.'input' => \&Mojolicious::Plugin::BootstrapHelpers::Helpers::bootstrap_input);
40 14         1346 $app->helper($tp.'navbar' => \&Mojolicious::Plugin::BootstrapHelpers::Helpers::bootstrap_navbar);
41 14         1065 $app->helper($tp.'nav' => \&Mojolicious::Plugin::BootstrapHelpers::Helpers::bootstrap_nav);
42              
43 14 50 33     1347 if(exists $args->{'icons'}{'class'} && $args->{'icons'}{'formatter'}) {
44 14         128 $app->config->{'Plugin::BootstrapHelpers'} = $args;
45 14         228 $app->helper($tp.'icon' => \&Mojolicious::Plugin::BootstrapHelpers::Helpers::bootstrap_icon);
46             }
47              
48 14 50       1109 if($init_shortcuts) {
49 14         42 my @sizes = qw/xsmall small medium large/;
50 14         55 my @contexts = qw/default active primary success info warning danger/;
51 14         29 my @table = qw/striped bordered hover condensed responsive/;
52 14         36 my @direction = qw/right left block vertical justified dropup/;
53 14         34 my @menu = qw/caret hamburger/;
54 14         40 my @misc = qw/disabled inverse/;
55              
56 14         36 foreach my $helper (@sizes, @contexts, @table, @direction, @menu, @misc) {
57 364     75   27583 $app->helper($ssp.$helper, sub { ("__$helper" => 1) });
  75         504336  
58             }
59             }
60             }
61              
62 28     28 0 50 sub setup_prefix($prefix) {
  28         53  
  28         49  
63 28 50 33     112 return defined $prefix && !length $prefix ? '_'
    50          
64             : defined $prefix ? $prefix
65             : ''
66             ;
67             }
68              
69             1;
70              
71             __END__