File Coverage

blib/lib/Pod/ProjectDocs/Template.pm
Criterion Covered Total %
statement 29 29 100.0
branch 1 2 50.0
condition n/a
subroutine 9 9 100.0
pod 0 1 0.0
total 39 41 95.1


line stmt bran cond sub pod time code
1             package Pod::ProjectDocs::Template;
2              
3 4     4   2732 use strict;
  4         11  
  4         123  
4 4     4   22 use warnings;
  4         8  
  4         181  
5              
6             our $VERSION = '0.53'; # VERSION
7              
8 4     4   20 use Moose::Role;
  4         10  
  4         33  
9              
10 4     4   23098 use Template;
  4         75792  
  4         136  
11 4     4   36 use File::Basename;
  4         10  
  4         211  
12 4     4   23 use File::Spec;
  4         9  
  4         68  
13 4     4   21 use Carp();
  4         8  
  4         1169  
14              
15             has '_curpath' => (
16             is => 'rw',
17             isa => 'Str',
18             default => '',
19             );
20              
21             has '_tt' => (
22             is => 'ro',
23             isa => 'Object',
24             default => sub {
25             my $self = shift;
26             Template->new(
27             {
28             FILTERS => {
29             relpath => sub {
30             my $path = shift;
31             my $curpath = $self->_curpath();
32             my ( $name, $dir ) = fileparse $curpath, qr/\.html/;
33             return File::Spec->abs2rel( $path, $dir );
34             },
35             return2br => sub {
36             my $text = shift;
37             $text =~ s!\r\n!<br />!g;
38             $text =~ s!\n!<br />!g;
39             return $text;
40             }
41             },
42             }
43             );
44             },
45             );
46              
47             sub process {
48 8     8 0 26 my ( $self, $doc, $data, $output ) = @_;
49 8         29 $self->_curpath( $doc->get_output_path );
50 8 50       229 $self->_tt()->process( \$data, $output, \my $text )
51             or Carp::croak( $self->_tt()->error );
52 8         21950 $self->_curpath('');
53 8         37 return $text;
54             }
55              
56 4     4   31 no Moose::Role;
  4         9  
  4         45  
57              
58             1;
59             __END__