File Coverage

blib/lib/Sledge/Plugin/Prototype.pm
Criterion Covered Total %
statement 12 27 44.4
branch 0 2 0.0
condition 0 3 0.0
subroutine 4 8 50.0
pod n/a
total 16 40 40.0


line stmt bran cond sub pod time code
1             package Sledge::Plugin::Prototype;
2              
3 1     1   32420 use strict;
  1         2  
  1         38  
4 1     1   6 use vars qw($VERSION);
  1         2  
  1         58  
5             $VERSION = '0.03';
6              
7 1     1   981 use HTML::Prototype;
  1         49796  
  1         19  
8              
9             sub import {
10 0     0     my $class = shift;
11 0           my $pkg = caller;
12 1     1   71 no strict 'refs';
  1         2  
  1         259  
13 0   0 0     *{"$pkg\::prototype"} = sub { $_[0]->{__prototype} ||= HTML::Prototype->new };
  0            
  0            
14 0           *{"$pkg\::show_prototype_js"} = sub {
15 0     0     my $self = shift;
16              
17 0           $self->r->content_type('text/javascript');
18 0           $self->r->send_http_header;
19 0           $self->r->print($HTML::Prototype::prototype);
20 0           $self->finished(1);
21 0           };
22             $pkg->register_hook(
23             BEFORE_DISPATCH => sub {
24 0     0     my $self = shift;
25 0 0         $self->tmpl->param(prototype=>$self->prototype)
26             if ref ($self->tmpl) =~ /^Sledge::Template::TT/;
27 0           } );
28             }
29              
30             1;
31             __END__