blib/lib/Galileo/Plugin/Modal.pm untested

filter: Statementstmt 0.0% 0 / 11 Branchbran 0.0% 0 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 2 Podpod 0.0% 0 / 1 totaltotal 0.0% 0 / 16 CC 2 SCAR 15.4
CC
2
Cov
0%
register
6.0
BEGIN
2.0
CRAP 4.7
1 package Galileo::Plugin::Modal;
2  
3 use Mojo::Base 'Mojolicious::Plugin';
4  
5 sub register {
6 my ($plugin, $app) = @_;
7  
8 push @{$app->renderer->classes}, __PACKAGE__;
9  
10 $app->helper( modal => sub {
11 my ($self, $id, $body) = @_;
12 $body = $body->() if ref $body;
13 return $self->render_to_string(
14 template => 'galileo_modal',
15 'galileo.modal.id' => $id,
16 'galileo.modal.body' => $body,
17 );
18 });
19 }
20  
21 1;
22  
23 __DATA__
24  
25 @@ galileo_modal.html.ep
26 <div class="modal hide fade" id="<%= stash 'galileo.modal.id' %>">
27 <div class="modal-header">
28 <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
29 <h3>Confirm Action</h3>
30 </div>
31 <div class="modal-body">
32 <p><%= stash 'galileo.modal.body' %></p>
33 </div>
34 <div class="modal-footer">
35 <a href="#" class="btn" data-dismiss="modal">Close</a>
36 <a href="#" class="btn btn-primary" data-dismiss="modal">Confirm</a>
37 </div>
38 </div>