line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package HTML::Template::Parser::TreeWriter; |
2
|
|
|
|
|
|
|
|
3
|
6
|
|
|
6
|
|
43
|
use strict; |
|
6
|
|
|
|
|
9
|
|
|
6
|
|
|
|
|
204
|
|
4
|
6
|
|
|
6
|
|
34
|
use warnings; |
|
6
|
|
|
|
|
11
|
|
|
6
|
|
|
|
|
161
|
|
5
|
|
|
|
|
|
|
|
6
|
6
|
|
|
6
|
|
30
|
use base qw(Class::Accessor::Fast); |
|
6
|
|
|
|
|
12
|
|
|
6
|
|
|
|
|
4495
|
|
7
|
|
|
|
|
|
|
__PACKAGE__->mk_accessors(qw( context )); |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
sub write { |
10
|
395
|
|
|
395
|
0
|
1531
|
my($self, $node) = @_; |
11
|
|
|
|
|
|
|
|
12
|
395
|
|
|
|
|
1268
|
my $type = $self->get_type($node); |
13
|
|
|
|
|
|
|
|
14
|
395
|
|
|
|
|
795
|
my $pre = "_pre_$type"; |
15
|
395
|
|
|
|
|
579
|
my $main = "_main_$type"; |
16
|
395
|
|
|
|
|
619
|
my $map = "_map_$type"; |
17
|
395
|
|
|
|
|
678
|
my $join = "_join_$type"; |
18
|
395
|
|
|
|
|
549
|
my $post = "_post_$type"; |
19
|
|
|
|
|
|
|
|
20
|
395
|
|
|
|
|
510
|
my $out = ''; |
21
|
|
|
|
|
|
|
|
22
|
395
|
100
|
|
|
|
1737
|
if($self->can($pre)){ |
23
|
171
|
|
|
|
|
566
|
$out .= $self->$pre($node); |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
|
26
|
395
|
100
|
|
|
|
1726
|
if($self->can($main)){ |
27
|
158
|
|
|
|
|
592
|
$out .= $self->$main($node); |
28
|
|
|
|
|
|
|
}else{ |
29
|
237
|
|
|
|
|
357
|
my @children_out; |
30
|
237
|
100
|
|
|
|
812
|
if ($self->can($map)) { |
31
|
13
|
|
|
|
|
59
|
@children_out = $self->$map($node); |
32
|
|
|
|
|
|
|
} else { |
33
|
224
|
|
|
|
|
680
|
@children_out = map { $self->write($_); } $self->get_node_children($node); |
|
173
|
|
|
|
|
774
|
|
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
237
|
100
|
|
|
|
1394
|
if ($self->can($join)) { |
37
|
13
|
|
|
|
|
59
|
$out .= $self->$join($node, \@children_out); |
38
|
|
|
|
|
|
|
} else { |
39
|
224
|
|
|
|
|
555
|
$out .= join('', @children_out); |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
395
|
50
|
|
|
|
1619
|
if($self->can($post)){ |
44
|
0
|
|
|
|
|
0
|
$out .= $self->$post($node); |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
395
|
|
|
|
|
2115
|
$out; |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
sub create_and_push_context { |
51
|
10
|
|
|
10
|
0
|
21
|
my $self = shift; |
52
|
10
|
|
|
|
|
18
|
my $new_context = {}; |
53
|
10
|
|
|
|
|
16
|
push(@{$self->context}, $new_context); |
|
10
|
|
|
|
|
24
|
|
54
|
10
|
|
|
|
|
62
|
$new_context; |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
sub pop_context { |
58
|
10
|
|
|
10
|
0
|
19
|
my $self = shift; |
59
|
10
|
50
|
|
|
|
13
|
if(@{$self->context} < 1){ |
|
10
|
|
|
|
|
24
|
|
60
|
0
|
|
|
|
|
0
|
die "Internal error. context is empty.\n"; |
61
|
|
|
|
|
|
|
} |
62
|
10
|
|
|
|
|
65
|
pop(@{$self->context}); |
|
10
|
|
|
|
|
25
|
|
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
sub get_context_depth { |
66
|
10
|
|
|
10
|
0
|
16
|
my $self = shift; |
67
|
10
|
|
|
|
|
15
|
scalar(@{$self->context}); |
|
10
|
|
|
|
|
33
|
|
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
sub current_context { |
71
|
62
|
|
|
62
|
0
|
89
|
my $self = shift; |
72
|
|
|
|
|
|
|
|
73
|
62
|
100
|
|
|
|
68
|
if(@{$self->context}){ |
|
62
|
|
|
|
|
183
|
|
74
|
22
|
|
|
|
|
130
|
return $self->context->[-1]; |
75
|
|
|
|
|
|
|
} |
76
|
40
|
|
|
|
|
373
|
return; |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
1; |