File Coverage

lib/Spoon/Template/TT2.pm
Criterion Covered Total %
statement 9 24 37.5
branch 0 6 0.0
condition n/a
subroutine 3 6 50.0
pod 0 3 0.0
total 12 39 30.7


line stmt bran cond sub pod time code
1             package Spoon::Template::TT2;
2 1     1   2331 use Spoon::Template -Base;
  1         2  
  1         15  
3 1     1   1027  
  1     1   2  
  1         34  
  1         5  
  1         3  
  1         294  
4             field template_object =>
5             -init => '$self->create_template_object';
6              
7 0     0 0   sub compile_dir {
8 0           my $dir = $self->plugin_directory . '/ttc';
9 0 0         mkdir $dir unless -d $dir;
10 0           return $dir;
11             }
12            
13 0     0 0   sub create_template_object {
14 0           require Template;
15             # XXX Make template caching a configurable option
16 0           Template->new({
17             INCLUDE_PATH => $self->path,
18             TOLERANT => 0,
19             COMPILE_DIR => $self->compile_dir,
20             COMPILE_EXT => '.ttc',
21             });
22             }
23              
24 0     0 0   sub render {
25 0           my $template = shift;
26              
27 0           my $output;
28 0           my $t = $self->template_object;
29 0           eval {
30 0 0         $t->process($template, {@_}, \$output) or die $t->error;
31             };
32 0 0         die "Template Toolkit error:\n$@" if $@;
33 0           return $output;
34             }
35              
36             __DATA__