File Coverage

blib/lib/Dancer/Template/Haml.pm
Criterion Covered Total %
statement 15 22 68.1
branch 0 4 0.0
condition 0 3 0.0
subroutine 5 7 71.4
pod 2 2 100.0
total 22 38 57.8


line stmt bran cond sub pod time code
1             package Dancer::Template::Haml;
2              
3 1     1   26477 use strict;
  1         3  
  1         36  
4 1     1   5 use warnings;
  1         1  
  1         31  
5              
6 1     1   1221 use Text::Haml;
  1         49899  
  1         42  
7              
8 1     1   13 use vars '$VERSION';
  1         2  
  1         177  
9 1     1   7 use base 'Dancer::Template::Abstract';
  1         2  
  1         1350  
10              
11             our $VERSION = '0.01';
12              
13             my $_engine;
14              
15 0     0 1   sub init { $_engine = Text::Haml->new }
16              
17             sub render($$$) {
18 0     0 1   my ($self, $template, $tokens) = @_;
19              
20 0           $template =~ s/\.tt$/\.haml/;
21              
22 0 0 0       die "'$template' is not a regular file"
23             if ref($template) || (!-f $template);
24              
25 0           my $content = q{};
26 0 0         $content = $_engine->render_file($template, %$tokens)
27             or die $_engine->error;
28 0           return $content;
29             }
30              
31             1;
32             __END__