line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package TemplateM::Galore; # $Id: Galore.pm 2 2013-04-02 10:51:49Z abalama $
|
2
|
6
|
|
|
6
|
|
34
|
use strict;
|
|
6
|
|
|
|
|
10
|
|
|
6
|
|
|
|
|
255
|
|
3
|
|
|
|
|
|
|
|
4
|
6
|
|
|
6
|
|
33
|
use base qw/Exporter/;
|
|
6
|
|
|
|
|
13
|
|
|
6
|
|
|
|
|
617
|
|
5
|
6
|
|
|
6
|
|
33
|
use vars qw($VERSION);
|
|
6
|
|
|
|
|
10
|
|
|
6
|
|
|
|
|
334
|
|
6
|
|
|
|
|
|
|
our $VERSION = 2.21;
|
7
|
|
|
|
|
|
|
|
8
|
6
|
|
|
6
|
|
30
|
use TemplateM::Util;
|
|
6
|
|
|
|
|
11
|
|
|
6
|
|
|
|
|
388
|
|
9
|
6
|
|
|
6
|
|
32
|
use Carp;
|
|
6
|
|
|
|
|
18
|
|
|
6
|
|
|
|
|
6826
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
our @EXPORT = qw/html/;
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub start {
|
14
|
1
|
|
|
1
|
0
|
2
|
my $self = shift;
|
15
|
1
|
|
|
|
|
2
|
my $label = shift;
|
16
|
1
|
50
|
|
|
|
5
|
croak("[start] Incorrect call of method \"start\"") unless (defined($label));
|
17
|
|
|
|
|
|
|
|
18
|
1
|
|
|
|
|
1
|
my $tpl = '';
|
19
|
1
|
|
|
|
|
3
|
my $wrk = '';
|
20
|
1
|
|
|
|
|
1
|
my $stk = '';
|
21
|
|
|
|
|
|
|
|
22
|
1
|
50
|
|
|
|
31
|
$tpl = $2 if $self->{work} =~ m/(.*?)/s;
|
23
|
|
|
|
|
|
|
|
24
|
1
|
|
|
|
|
18
|
return bless {
|
25
|
|
|
|
|
|
|
template => $tpl,
|
26
|
|
|
|
|
|
|
work => $wrk,
|
27
|
|
|
|
|
|
|
stackout => $stk,
|
28
|
|
|
|
|
|
|
label => $label,
|
29
|
|
|
|
|
|
|
pobj => $self,
|
30
|
|
|
|
|
|
|
tf => 1
|
31
|
|
|
|
|
|
|
};
|
32
|
|
|
|
|
|
|
}
|
33
|
|
|
|
|
|
|
sub loop {
|
34
|
11
|
|
|
11
|
0
|
33
|
my $self = shift;
|
35
|
11
|
|
|
|
|
12
|
my $hr = $_[0];
|
36
|
|
|
|
|
|
|
|
37
|
11
|
50
|
|
|
|
19
|
croak("[loop] Incorrect call of method \"loop\"") unless (defined($hr));
|
38
|
|
|
|
|
|
|
|
39
|
11
|
50
|
33
|
|
|
42
|
if (defined($hr) && (ref($hr) ne "HASH")) {
|
40
|
11
|
50
|
|
|
|
18
|
if (ref($hr) eq "ARRAY") {
|
41
|
0
|
|
|
|
|
0
|
$hr = {@$hr};
|
42
|
|
|
|
|
|
|
} else {
|
43
|
11
|
|
|
|
|
25
|
$hr = {@_};
|
44
|
|
|
|
|
|
|
}
|
45
|
|
|
|
|
|
|
}
|
46
|
|
|
|
|
|
|
|
47
|
11
|
|
|
|
|
18
|
$self->{stackout} .= $self->{work};
|
48
|
|
|
|
|
|
|
|
49
|
11
|
|
|
|
|
15
|
my $wrk = $self->{template};
|
50
|
|
|
|
|
|
|
|
51
|
11
|
50
|
|
|
|
55
|
$wrk =~ s//_exec_directive($hr,$1,'val')/ieg if defined($hr);
|
|
11
|
|
|
|
|
17
|
|
52
|
|
|
|
|
|
|
|
53
|
11
|
|
|
|
|
34
|
$self->{work} = $wrk
|
54
|
|
|
|
|
|
|
}
|
55
|
|
|
|
|
|
|
sub finish {
|
56
|
1
|
|
|
1
|
0
|
7
|
my $self = shift;
|
57
|
|
|
|
|
|
|
|
58
|
1
|
|
|
|
|
2
|
$self->{stackout} .= $self->{work};
|
59
|
|
|
|
|
|
|
|
60
|
1
|
|
|
|
|
3
|
$self->{work} = '';
|
61
|
|
|
|
|
|
|
|
62
|
1
|
|
|
|
|
2
|
my $label = $self->{label};
|
63
|
1
|
|
|
|
|
3
|
my $stack = $self->{stackout};
|
64
|
|
|
|
|
|
|
|
65
|
1
|
50
|
|
|
|
4
|
if ($self->{pobj}->{tf}) {
|
66
|
0
|
|
|
|
|
0
|
$self->{pobj}->{work} =~ s/(.*?)/$stack/s
|
67
|
|
|
|
|
|
|
} else {
|
68
|
1
|
|
|
|
|
7
|
$self->{pobj}->{looparr}->{$self->{label}} = $stack
|
69
|
|
|
|
|
|
|
}
|
70
|
|
|
|
|
|
|
}
|
71
|
0
|
|
|
0
|
0
|
0
|
sub finalize { goto &finish }
|
72
|
|
|
|
|
|
|
sub cast {
|
73
|
1
|
|
|
1
|
0
|
3
|
my $self = shift;
|
74
|
1
|
|
|
|
|
3
|
my $hr = $_[0];
|
75
|
|
|
|
|
|
|
|
76
|
1
|
50
|
|
|
|
6
|
croak("[cast] Incorrect call of method \"cast\"") unless (defined $hr);
|
77
|
|
|
|
|
|
|
|
78
|
1
|
50
|
|
|
|
3
|
unless (ref($hr) eq "HASH") {
|
79
|
1
|
|
|
|
|
3
|
$hr = {@_};
|
80
|
|
|
|
|
|
|
}
|
81
|
|
|
|
|
|
|
|
82
|
1
|
|
|
|
|
10
|
$self->{work} =~ s//_exec_directive($hr, $1, 'cgi')/ieg;
|
|
1
|
|
|
|
|
5
|
|
83
|
|
|
|
|
|
|
}
|
84
|
1
|
|
|
1
|
0
|
4
|
sub stash { goto &cast }
|
85
|
|
|
|
|
|
|
sub ifelse {
|
86
|
2
|
|
|
2
|
0
|
3
|
my $self = shift;
|
87
|
2
|
|
50
|
|
|
8
|
my $label = shift || '';
|
88
|
2
|
|
100
|
|
|
11
|
my $predicate = shift || 0;
|
89
|
|
|
|
|
|
|
|
90
|
2
|
50
|
|
|
|
6
|
croak("[efelse] Incorrect call of method \"ifelse\"") unless (defined($label));
|
91
|
|
|
|
|
|
|
|
92
|
2
|
100
|
|
|
|
8
|
if ($predicate) {
|
93
|
1
|
|
|
|
|
58
|
$self->{work} =~ s/(.*?)/$2/igs;
|
94
|
1
|
|
|
|
|
42
|
$self->{work} =~ s/.*?//igs;
|
95
|
|
|
|
|
|
|
} else {
|
96
|
1
|
|
|
|
|
43
|
$self->{work} =~ s/(.*?)/$2/igs;
|
97
|
1
|
|
|
|
|
45
|
$self->{work} =~ s/.*?//igs;
|
98
|
|
|
|
|
|
|
}
|
99
|
|
|
|
|
|
|
}
|
100
|
2
|
|
|
2
|
0
|
10
|
sub cast_if { goto &ifelse }
|
101
|
|
|
|
|
|
|
sub output {
|
102
|
5
|
|
|
5
|
0
|
24
|
my $self = shift;
|
103
|
5
|
|
50
|
|
|
41
|
my $property = shift || 'stackout';
|
104
|
|
|
|
|
|
|
|
105
|
5
|
50
|
33
|
|
|
53
|
if (! $self->{tf} and $property eq 'stackout') {
|
106
|
5
|
|
|
|
|
23
|
$self->{work} =~ s/(.*?)/_analize($self->{looparr},$1)/egs;
|
|
1
|
|
|
|
|
4
|
|
107
|
5
|
|
|
|
|
25
|
$self->{stackout} = $self->{work};
|
108
|
|
|
|
|
|
|
}
|
109
|
5
|
50
|
|
|
|
40
|
return defined($self->{$property}) ? $self->{$property} : ''
|
110
|
|
|
|
|
|
|
}
|
111
|
|
|
|
|
|
|
sub html {
|
112
|
0
|
|
|
0
|
0
|
0
|
my $self = shift;
|
113
|
0
|
|
0
|
|
|
0
|
my $header = $self->{header} || '';
|
114
|
0
|
0
|
|
|
|
0
|
($header) = read_attributes([['HEAD','HEADER']],@_) if (defined $_[0]);
|
115
|
|
|
|
|
|
|
|
116
|
0
|
|
|
|
|
0
|
return $header . $self->output()
|
117
|
|
|
|
|
|
|
}
|
118
|
|
|
|
|
|
|
sub _exec_directive {
|
119
|
12
|
|
|
12
|
|
22
|
my ($hr, $directive, $sig) = @_;
|
120
|
|
|
|
|
|
|
|
121
|
12
|
50
|
|
|
|
35
|
if (defined($hr->{$directive})) {
|
122
|
12
|
|
|
|
|
45
|
return $hr->{$directive};
|
123
|
|
|
|
|
|
|
} else {
|
124
|
0
|
0
|
|
|
|
0
|
return $sig?(''):'';
|
125
|
|
|
|
|
|
|
}
|
126
|
|
|
|
|
|
|
}
|
127
|
|
|
|
|
|
|
sub _analize {
|
128
|
1
|
|
|
1
|
|
2
|
my ($hr, $directive) = @_;
|
129
|
1
|
50
|
|
|
|
4
|
if (defined($hr->{$directive})) {
|
130
|
1
|
|
|
|
|
3
|
return $hr->{$directive}
|
131
|
|
|
|
|
|
|
}
|
132
|
0
|
|
|
|
|
|
return ''
|
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
}
|
135
|
|
|
|
|
|
|
1;
|
136
|
|
|
|
|
|
|
|