| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package HTML::Template::Default; |
|
2
|
2
|
|
|
2
|
|
36495
|
use strict; |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
52
|
|
|
3
|
2
|
|
|
2
|
|
10
|
use Carp; |
|
|
2
|
|
|
|
|
3
|
|
|
|
2
|
|
|
|
|
159
|
|
|
4
|
2
|
|
|
2
|
|
10
|
use base 'HTML::Template'; |
|
|
2
|
|
|
|
|
7
|
|
|
|
2
|
|
|
|
|
3294
|
|
|
5
|
2
|
|
|
2
|
|
45088
|
use LEOCHARRE::Debug; |
|
|
2
|
|
|
|
|
1040
|
|
|
|
2
|
|
|
|
|
12
|
|
|
6
|
2
|
|
|
2
|
|
101
|
use vars qw(@EXPORT_OK @ISA %EXPORT_TAGS $VERSION); |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
1898
|
|
|
7
|
|
|
|
|
|
|
@ISA = qw(Exporter); |
|
8
|
|
|
|
|
|
|
@EXPORT_OK = qw(get_tmpl); |
|
9
|
|
|
|
|
|
|
%EXPORT_TAGS = ( |
|
10
|
|
|
|
|
|
|
all => \@EXPORT_OK, |
|
11
|
|
|
|
|
|
|
); |
|
12
|
|
|
|
|
|
|
$VERSION = sprintf "%d.%02d", q$Revision: 1.10 $ =~ /(\d+)/g; |
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub _get_abs_tmpl { |
|
16
|
6
|
|
|
6
|
|
20
|
my $filename = shift; |
|
17
|
6
|
100
|
50
|
|
|
24
|
$filename or debug('no filename provided') and return; |
|
18
|
|
|
|
|
|
|
#$filename or die('missing filename argument to get_tmpl'); |
|
19
|
|
|
|
|
|
|
|
|
20
|
4
|
|
|
|
|
7
|
my @possible_abs; |
|
21
|
|
|
|
|
|
|
|
|
22
|
4
|
|
|
|
|
22
|
for my $envar ( $ENV{HTML_TEMPLATE_ROOT}, $ENV{TMPL_PATH}, $ENV{HTML_TEMPLATE_ROOT} ){ |
|
23
|
12
|
100
|
|
|
|
34
|
defined $envar or next; |
|
24
|
8
|
|
|
|
|
27
|
push @possible_abs, "$envar/$filename"; |
|
25
|
|
|
|
|
|
|
} |
|
26
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
# lastly try the filename |
|
28
|
4
|
|
|
|
|
11
|
push @possible_abs, $filename; |
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
|
|
31
|
4
|
|
|
|
|
11
|
for my $abs ( @possible_abs ){ |
|
32
|
6
|
100
|
|
|
|
205
|
if( -f $abs ){ |
|
33
|
3
|
|
|
|
|
18
|
debug("file found: $abs"); |
|
34
|
3
|
|
|
|
|
66
|
return $abs; |
|
35
|
|
|
|
|
|
|
} |
|
36
|
|
|
|
|
|
|
else { |
|
37
|
3
|
|
|
|
|
15
|
debug("file not found: $abs"); |
|
38
|
|
|
|
|
|
|
} |
|
39
|
|
|
|
|
|
|
} |
|
40
|
|
|
|
|
|
|
|
|
41
|
1
|
|
|
|
|
16
|
debug("$filename : not found on disk.\n"); |
|
42
|
1
|
|
|
|
|
22
|
return; |
|
43
|
|
|
|
|
|
|
} |
|
44
|
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
sub get_tmpl { |
|
50
|
6
|
100
|
|
6
|
1
|
7299
|
if( scalar @_ > 3 ){ |
|
51
|
3
|
|
|
|
|
12
|
debug('over'); |
|
52
|
3
|
|
|
|
|
55
|
return tmpl(@_); |
|
53
|
|
|
|
|
|
|
} |
|
54
|
|
|
|
|
|
|
else { |
|
55
|
3
|
|
|
|
|
35
|
debug('under'); |
|
56
|
3
|
|
|
|
|
91
|
my %arg; |
|
57
|
3
|
|
|
|
|
19
|
for (@_){ |
|
58
|
6
|
100
|
|
|
|
29
|
defined $_ or next; |
|
59
|
5
|
100
|
|
|
|
23
|
if( ref $_ eq 'SCALAR' ){ |
|
60
|
3
|
|
|
|
|
13
|
$arg{scalarref} = $_; |
|
61
|
3
|
|
|
|
|
16
|
next; |
|
62
|
|
|
|
|
|
|
} |
|
63
|
2
|
|
|
|
|
23
|
$arg{filename} = $_; |
|
64
|
|
|
|
|
|
|
} |
|
65
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
# insert my default params |
|
67
|
3
|
|
|
|
|
16
|
$arg{die_on_bad_params} = 0; |
|
68
|
|
|
|
|
|
|
|
|
69
|
3
|
|
|
|
|
24
|
return tmpl(%arg); |
|
70
|
|
|
|
|
|
|
} |
|
71
|
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
} |
|
73
|
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
sub tmpl { |
|
75
|
6
|
|
|
6
|
0
|
27
|
my %a = @_; |
|
76
|
6
|
50
|
|
|
|
19
|
defined %a or confess('missing argument'); |
|
77
|
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
### %a |
|
79
|
|
|
|
|
|
|
|
|
80
|
6
|
100
|
|
|
|
49
|
my $debug = sprintf 'using filename: %s, using scalarref: %s', |
|
|
|
100
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
( $a{filename} ? $a{filename} : 'undef' ), |
|
82
|
|
|
|
|
|
|
( $a{scalarref} ? 1 : 0 ), |
|
83
|
|
|
|
|
|
|
; |
|
84
|
|
|
|
|
|
|
|
|
85
|
6
|
50
|
66
|
|
|
42
|
$a{filename} or $a{scalarref} or confess("no filename or scalarref provided"); |
|
86
|
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
|
|
88
|
6
|
100
|
|
|
|
31
|
if( my $abs = _get_abs_tmpl($a{filename})){ |
|
89
|
|
|
|
|
|
|
|
|
90
|
3
|
|
|
|
|
15
|
my %_a = %a; |
|
91
|
|
|
|
|
|
|
#if there is a scalarref, delete it |
|
92
|
3
|
|
|
|
|
8
|
delete $_a{scalarref}; |
|
93
|
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
#replace filename with what we resolved.. |
|
95
|
3
|
|
|
|
|
7
|
$_a{filename} = $abs; |
|
96
|
|
|
|
|
|
|
|
|
97
|
3
|
50
|
|
|
|
15
|
if ( my $tmpl = HTML::Template->new(%_a) ){ |
|
98
|
3
|
|
|
|
|
4015
|
debug("filename, $debug"); |
|
99
|
3
|
|
|
|
|
95
|
return $tmpl; |
|
100
|
|
|
|
|
|
|
} |
|
101
|
|
|
|
|
|
|
} |
|
102
|
|
|
|
|
|
|
|
|
103
|
3
|
50
|
|
|
|
57
|
if( $a{scalarref} ){ |
|
104
|
|
|
|
|
|
|
|
|
105
|
3
|
|
|
|
|
16
|
my %_a = %a; |
|
106
|
|
|
|
|
|
|
#if there is a filename, delete it |
|
107
|
3
|
|
|
|
|
7
|
delete $_a{filename}; |
|
108
|
|
|
|
|
|
|
|
|
109
|
3
|
50
|
|
|
|
250
|
if ( my $tmpl = HTML::Template->new(%_a) ){ |
|
110
|
3
|
|
|
|
|
2179
|
debug("scalarref - $debug"); |
|
111
|
3
|
|
|
|
|
97
|
return $tmpl; |
|
112
|
|
|
|
|
|
|
} |
|
113
|
|
|
|
|
|
|
} |
|
114
|
|
|
|
|
|
|
|
|
115
|
0
|
|
|
|
|
0
|
carp(__PACKAGE__ ."::tmpl() can't instance a template - $debug"); |
|
116
|
0
|
|
|
|
|
0
|
return; |
|
117
|
|
|
|
|
|
|
} |
|
118
|
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
# NEW VERSION... by overriding new in HTML::Template.... |
|
123
|
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
sub new { |
|
129
|
4
|
|
|
4
|
0
|
8557
|
my $class = shift; |
|
130
|
4
|
|
|
|
|
27
|
my %opt = @_; |
|
131
|
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
# for this to be of any use there must be |
|
133
|
4
|
100
|
66
|
|
|
109
|
$opt{filename} # at least a filename source |
|
|
|
|
66
|
|
|
|
|
|
134
|
|
|
|
|
|
|
and ( $opt{filehandle} or $opt{arrayref} or $opt{scalarref} ) # and at least a default source passed as argument |
|
135
|
|
|
|
|
|
|
#or return $class->SUPER::new( %opt ); # otherwise we add nothing, and revert to regular HTML::Template |
|
136
|
|
|
|
|
|
|
or return HTML::Template->new( %opt ); # otherwise we add nothing, and revert to regular HTML::Template |
|
137
|
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
# ok, at this point we know we have a filename source and some other source |
|
140
|
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
# we need to test the filename source, if it is valid, remove the other source(s) |
|
142
|
2
|
100
|
50
|
|
|
51
|
if ( |
|
143
|
|
|
|
|
|
|
HTML::Template::_find_file( # in HTML::Template |
|
144
|
|
|
|
|
|
|
{ options => { path => ($opt{path} || []) } }, # pseudo 'self' |
|
145
|
|
|
|
|
|
|
$opt{filename}, |
|
146
|
|
|
|
|
|
|
) |
|
147
|
|
|
|
|
|
|
){ |
|
148
|
1
|
50
|
|
|
|
168
|
$DEBUG and Carp::cluck('# found file, deleting other sources'); |
|
149
|
1
|
|
|
|
|
58
|
delete $opt{filehandle}; |
|
150
|
1
|
|
|
|
|
1
|
delete $opt{arrayref}; |
|
151
|
1
|
|
|
|
|
2
|
delete $opt{scalarref}; |
|
152
|
|
|
|
|
|
|
} |
|
153
|
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
else { |
|
155
|
1
|
50
|
|
|
|
704
|
$DEBUG and Carp::cluck('# did not find file, deleting filename source'); |
|
156
|
1
|
|
|
|
|
123
|
delete $opt{filename}; |
|
157
|
|
|
|
|
|
|
} |
|
158
|
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
#$class->SUPER::new( %opt ); |
|
160
|
2
|
|
|
|
|
29
|
HTML::Template->new( %opt ); |
|
161
|
|
|
|
|
|
|
} |
|
162
|
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
1; |