File Coverage

blib/lib/Pinwheel/Helpers/SSI.pm
Criterion Covered Total %
statement 29 29 100.0
branch 8 8 100.0
condition n/a
subroutine 9 9 100.0
pod 0 5 0.0
total 46 51 90.2


line stmt bran cond sub pod time code
1             package Pinwheel::Helpers::SSI;
2              
3 4     4   30212 use strict;
  4         8  
  4         140  
4 4     4   20 use warnings;
  4         9  
  4         116  
5              
6 4     4   19 use Exporter;
  4         9  
  4         176  
7              
8             require Pinwheel::Controller;
9 4     4   649 use Pinwheel::View::String;
  4         9  
  4         1769  
10              
11             our @ISA = qw(Exporter);
12             our @EXPORT_OK = qw(
13             ssi_if_exists
14             ssi_if_not_exists
15             ssi_include
16             ssi_set
17             );
18              
19              
20             sub ssi_if_exists
21             {
22 2     2 0 11 my $fn = pop;
23 2 100       14 my $path = (scalar(@_) > 1) ? Pinwheel::Controller::url_for(@_) : shift;
24 2         6 return ssi_flastmod($path, '!=', [&$fn()]);
25             }
26              
27             sub ssi_if_not_exists
28             {
29 2     2 0 4 my $fn = pop;
30 2 100       13 my $path = (scalar(@_) > 1) ? Pinwheel::Controller::url_for(@_) : shift;
31 2         9 return ssi_flastmod($path, '=', [&$fn()]);
32             }
33              
34             sub ssi_flastmod
35             {
36             # Not exposed to the templates, but useful as a building block for other
37             # helpers
38 7     7 0 70 my ($path, $cond, $content, $else_content) = @_;
39 7         8 my ($s);
40              
41 7         30 $s = [
42             ['\n"],
43             ['' . "\n"],
44             $content,
45             ];
46 7 100       25 push @$s, ["\n"], $else_content if defined($else_content);
47 7         17 push @$s, ["\n"];
48              
49 7         25 return Pinwheel::View::String->new($s);
50             }
51              
52             sub ssi_include
53             {
54 4     4 0 18 my ($path);
55              
56 4 100       17 $path = (scalar(@_) > 1) ? Pinwheel::Controller::url_for(@_) : shift;
57 4         29 return Pinwheel::View::String->new([
58             ['']
59             ]);
60             }
61              
62             sub ssi_set
63             {
64 4     4 0 461 my ($var, $value) = @_;
65              
66 4         25 return Pinwheel::View::String->new([
67             [''],
68             ]);
69             }
70              
71              
72             1;