line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package HTML::Template::Extension::CSTART; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
$VERSION = "0.24"; |
4
|
0
|
|
|
0
|
0
|
0
|
sub Version { $VERSION; } |
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
5
|
use Carp; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
84
|
|
7
|
1
|
|
|
1
|
|
6
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
485
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
my %fields_parent = |
10
|
|
|
|
|
|
|
( |
11
|
|
|
|
|
|
|
ecp_compatibility_mode => 0, |
12
|
|
|
|
|
|
|
); |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
my $re_var = q{ |
15
|
|
|
|
|
|
|
<\s* |
16
|
|
|
|
|
|
|
[Tt][Mm][Pp][Ll]_[Cc][Ss][Tt][Aa][Rr][Tt] |
17
|
|
|
|
|
|
|
\s*> |
18
|
|
|
|
|
|
|
(.*?) |
19
|
|
|
|
|
|
|
<\s*\/[Tt][Mm][Pp][Ll]_[Cc][Ss][Tt][Aa][Rr][Tt]\s*>}; |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub init { |
23
|
1
|
|
|
1
|
0
|
4
|
my $self = shift; |
24
|
1
|
|
|
|
|
6
|
while (my ($key,$val) = each(%fields_parent)) { |
25
|
1
|
|
33
|
|
|
11
|
$self->{$key} = $self->{$key} || $val; |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub push_filter { |
30
|
1
|
|
|
1
|
0
|
2
|
my $self = shift; |
31
|
1
|
|
|
|
|
1
|
push @{$self->{filter_internal}},@{_get_filter($self)}; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
2
|
|
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub _get_filter { |
35
|
1
|
|
|
1
|
|
2
|
my $self = shift; |
36
|
1
|
|
|
|
|
1
|
my @ret ; |
37
|
|
|
|
|
|
|
# Sorry for this :->. I've an e-commerce project called ecp that |
38
|
|
|
|
|
|
|
# use a CSTART modified syntax using html comment |
39
|
1
|
50
|
|
|
|
3
|
push @ret,\&_ecp_cstart if ($self->{ecp_compatibility_mode}); |
40
|
|
|
|
|
|
|
# Standard CSTART syntax |
41
|
1
|
|
|
|
|
3
|
push @ret,\&_cstart; |
42
|
1
|
|
|
|
|
4
|
return \@ret; |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
# funzione filtro per aggiungere il tag |
47
|
|
|
|
|
|
|
# da tenere fintanto che la nostra patch non sia inserita nella |
48
|
|
|
|
|
|
|
# distribuzione standard del modulo |
49
|
|
|
|
|
|
|
sub _cstart { |
50
|
1
|
|
|
1
|
|
14
|
my $template = shift; |
51
|
1
|
|
|
|
|
2
|
my $ret = ''; |
52
|
1
|
|
|
|
|
54
|
while ($$template =~m{$re_var}xsg) { |
53
|
2
|
|
|
|
|
12
|
$ret .= $1; |
54
|
|
|
|
|
|
|
} |
55
|
1
|
50
|
|
|
|
5
|
$$template = $ret eq '' ? $$template : $ret; |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
sub _ecp_cstart { |
59
|
0
|
|
|
0
|
|
|
my $template = shift; |
60
|
0
|
|
|
|
|
|
my $brem ='
|
61
|
0
|
|
|
|
|
|
my $eend ='--' . '>'; |
62
|
0
|
|
|
|
|
|
my $start = qq=$brem\\s*[Cc][Ss][Tt][Aa][Rr][Tt]\\s*$eend=; |
63
|
0
|
|
|
|
|
|
my $end = qq=$brem\\s*[Cc][Ee][Nn][Dd]\\s*$eend=; |
64
|
0
|
0
|
|
|
|
|
if ($$template =~/$end/) { |
65
|
0
|
|
|
|
|
|
$$template =~s|$start||g; |
66
|
0
|
|
|
|
|
|
$$template =~s|$end||g; |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
1; |