File Coverage

lib/Spoon/Template.pm
Criterion Covered Total %
statement 24 37 64.8
branch 0 4 0.0
condition n/a
subroutine 7 10 70.0
pod 1 6 16.6
total 32 57 56.1


line stmt bran cond sub pod time code
1             package Spoon::Template;
2 3     3   1859 use Spoon::Base -Base;
  3         7  
  3         36  
3 3     3   2503 use Template;
  3     3   7  
  3     3   118  
  3         17  
  3         7  
  3         98  
  3         4689  
  3         85654  
  3         1512  
4              
5             const class_id => 'template';
6             const template_path => [ './template' ];
7             field path => [];
8             stub 'render';
9             field config => -init => '$self->hub->config';
10             field cgi => -init => '$self->hub->cgi';
11              
12 1     1 1 2 sub init {
13 1         1 $self->add_path(@{$self->template_path});
  1         3  
14             }
15              
16 0     0 0 0 sub all {
17             return (
18 0 0       0 $self->config->all,
19             $self->is_in_cgi ? ($self->cgi->all) : (),
20             hub => $self->hub,
21             );
22             }
23              
24 1     1 0 5 sub add_path {
25 1         3 for (reverse @_) {
26 1         3 $self->remove_path($_);
27 1         12 unshift @{$self->path}, $_;
  1         22  
28             }
29             }
30              
31 0     0 0 0 sub append_path {
32 0         0 for (@_) {
33 0         0 $self->remove_path($_);
34 0         0 push @{$self->path}, $_;
  0         0  
35             }
36             }
37              
38 1     1 0 2 sub remove_path {
39 1         2 my $path = shift;
40 1         1 $self->path([grep {$_ ne $path} @{$self->path}]);
  0         0  
  1         23  
41             }
42              
43 0     0 0   sub process {
44 0           my $template = shift;
45 0 0         my @templates = (ref $template eq 'ARRAY')
46             ? @$template
47             : $template;
48 0           return join '', map {
49 0           $self->render($_, $self->all, @_)
50             } @templates;
51             }
52              
53             __END__