| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package DTL::Fast::Entity; |
|
2
|
98
|
|
|
98
|
|
30364
|
use strict; |
|
|
98
|
|
|
|
|
193
|
|
|
|
98
|
|
|
|
|
2130
|
|
|
3
|
98
|
|
|
98
|
|
414
|
use utf8; |
|
|
98
|
|
|
|
|
163
|
|
|
|
98
|
|
|
|
|
365
|
|
|
4
|
98
|
|
|
98
|
|
1965
|
use warnings FATAL => 'all'; |
|
|
98
|
|
|
|
|
164
|
|
|
|
98
|
|
|
|
|
2761
|
|
|
5
|
|
|
|
|
|
|
# prototype for template entity. Handling current line and current template references |
|
6
|
|
|
|
|
|
|
|
|
7
|
98
|
|
|
98
|
|
467
|
use Scalar::Util qw(weaken); |
|
|
98
|
|
|
|
|
171
|
|
|
|
98
|
|
|
|
|
7113
|
|
|
8
|
98
|
|
|
98
|
|
620
|
use Carp qw(confess); |
|
|
98
|
|
|
|
|
192
|
|
|
|
98
|
|
|
|
|
57418
|
|
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub new |
|
11
|
|
|
|
|
|
|
{ |
|
12
|
8071
|
|
|
8071
|
0
|
21896
|
my ( $proto, %kwargs ) = @_; |
|
13
|
|
|
|
|
|
|
|
|
14
|
8071
|
|
33
|
|
|
25034
|
$proto = ref $proto || $proto; |
|
15
|
|
|
|
|
|
|
|
|
16
|
8071
|
|
66
|
|
|
63920
|
$DTL::Fast::Template::CURRENT_TEMPLATE->{modules}->{$proto} = $proto->VERSION // DTL::Fast->VERSION; |
|
17
|
|
|
|
|
|
|
|
|
18
|
8071
|
|
|
|
|
32894
|
my $self = bless { %kwargs }, $proto; |
|
19
|
|
|
|
|
|
|
|
|
20
|
8071
|
|
|
|
|
22331
|
$self->remember_template; |
|
21
|
|
|
|
|
|
|
|
|
22
|
8071
|
|
|
|
|
24238
|
return $self; |
|
23
|
|
|
|
|
|
|
} |
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub remember_template |
|
26
|
|
|
|
|
|
|
{ |
|
27
|
7109
|
|
|
7109
|
0
|
11385
|
my ($self) = @_; |
|
28
|
|
|
|
|
|
|
|
|
29
|
7109
|
|
|
|
|
12869
|
$self->{_template} = $DTL::Fast::Template::CURRENT_TEMPLATE; |
|
30
|
7109
|
|
|
|
|
11122
|
$self->{_template_line} = $DTL::Fast::Template::CURRENT_TEMPLATE_LINE; |
|
31
|
7109
|
|
|
|
|
18502
|
weaken $self->{_template}; |
|
32
|
|
|
|
|
|
|
|
|
33
|
7109
|
|
|
|
|
11073
|
return $self; |
|
34
|
|
|
|
|
|
|
} |
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub get_parse_error |
|
37
|
|
|
|
|
|
|
{ |
|
38
|
18
|
|
|
18
|
0
|
63
|
my ($self, $message, @messages) = @_; |
|
39
|
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
return $self->compile_error_message( |
|
41
|
|
|
|
|
|
|
'Parsing error' => $message // 'undef' |
|
42
|
|
|
|
|
|
|
, Template => $DTL::Fast::Template::CURRENT_TEMPLATE->{file_path} |
|
43
|
18
|
|
50
|
|
|
137
|
, Line => $DTL::Fast::Template::CURRENT_TEMPLATE_LINE |
|
44
|
|
|
|
|
|
|
, @messages |
|
45
|
|
|
|
|
|
|
); |
|
46
|
|
|
|
|
|
|
} |
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub get_parse_warning |
|
49
|
|
|
|
|
|
|
{ |
|
50
|
12
|
|
|
12
|
0
|
41
|
my ($self, $message, @messages) = @_; |
|
51
|
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
return $self->compile_error_message( |
|
53
|
|
|
|
|
|
|
'Parsing warning' => $message // 'undef' |
|
54
|
|
|
|
|
|
|
, Template => $DTL::Fast::Template::CURRENT_TEMPLATE->{file_path} |
|
55
|
12
|
|
50
|
|
|
88
|
, Line => $DTL::Fast::Template::CURRENT_TEMPLATE_LINE |
|
56
|
|
|
|
|
|
|
, @messages |
|
57
|
|
|
|
|
|
|
); |
|
58
|
|
|
|
|
|
|
} |
|
59
|
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
sub get_render_error |
|
61
|
|
|
|
|
|
|
{ |
|
62
|
12
|
|
|
12
|
0
|
34
|
my ($self, $context, $message, @messages) = @_; |
|
63
|
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
my @params = ( |
|
65
|
|
|
|
|
|
|
'Rendering error' => $message // 'undef' |
|
66
|
|
|
|
|
|
|
, Template => $self->{_template}->{file_path} |
|
67
|
|
|
|
|
|
|
, Line => $self->{_template_line} |
|
68
|
|
|
|
|
|
|
, @messages |
|
69
|
12
|
|
50
|
|
|
59
|
); |
|
70
|
|
|
|
|
|
|
|
|
71
|
12
|
50
|
|
|
|
33
|
confess "No context passed for rendering error generator." unless ($context); |
|
72
|
|
|
|
|
|
|
|
|
73
|
12
|
100
|
33
|
|
|
76
|
if ( |
|
|
|
|
66
|
|
|
|
|
|
74
|
|
|
|
|
|
|
exists $context->{ns}->[- 1]->{_dtl_include_path} |
|
75
|
|
|
|
|
|
|
and ref $context->{ns}->[- 1]->{_dtl_include_path} eq 'ARRAY' |
|
76
|
12
|
|
|
|
|
50
|
and scalar @{$context->{ns}->[- 1]->{_dtl_include_path}} > 1 |
|
77
|
|
|
|
|
|
|
) # has inclusions, appending stack trace |
|
78
|
|
|
|
|
|
|
{ |
|
79
|
2
|
|
|
|
|
6
|
push @params, 'Stack trace' => join( "\n", reverse @{$context->{ns}->[- 1]->{_dtl_include_path}}); |
|
|
2
|
|
|
|
|
5
|
|
|
80
|
|
|
|
|
|
|
} |
|
81
|
|
|
|
|
|
|
|
|
82
|
12
|
|
|
|
|
47
|
return $self->compile_error_message( @params ); |
|
83
|
|
|
|
|
|
|
} |
|
84
|
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
# format error message from key=>val pair |
|
86
|
|
|
|
|
|
|
sub compile_error_message |
|
87
|
|
|
|
|
|
|
{ |
|
88
|
42
|
|
|
42
|
0
|
152
|
my ($self, @messages) = @_; |
|
89
|
|
|
|
|
|
|
|
|
90
|
42
|
50
|
|
|
|
145
|
die 'Odd parameters in messages array' |
|
91
|
|
|
|
|
|
|
if (scalar(@messages) % 2); |
|
92
|
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
# calculating max padding |
|
94
|
42
|
|
|
|
|
74
|
my $padding = 0; |
|
95
|
42
|
|
|
|
|
150
|
for (my $i = 0; $i < scalar @messages; $i += 2) |
|
96
|
|
|
|
|
|
|
{ |
|
97
|
147
|
|
|
|
|
242
|
my $length = length $messages[$i]; |
|
98
|
147
|
100
|
|
|
|
484
|
$padding = $length if ($length > $padding); |
|
99
|
|
|
|
|
|
|
} |
|
100
|
|
|
|
|
|
|
|
|
101
|
42
|
|
|
|
|
89
|
my $result = ''; |
|
102
|
42
|
|
|
|
|
116
|
while ( scalar @messages ) |
|
103
|
|
|
|
|
|
|
{ |
|
104
|
147
|
|
50
|
|
|
373
|
my $key = shift @messages // 'undef'; |
|
105
|
147
|
|
50
|
|
|
336
|
my $value = shift @messages // 'undef'; |
|
106
|
|
|
|
|
|
|
|
|
107
|
147
|
|
|
|
|
274
|
chomp($value); |
|
108
|
|
|
|
|
|
|
|
|
109
|
147
|
|
|
|
|
200
|
my $key_length = length $key; |
|
110
|
|
|
|
|
|
|
|
|
111
|
147
|
|
|
|
|
475
|
$result .= sprintf |
|
112
|
|
|
|
|
|
|
'%s%s: ' |
|
113
|
|
|
|
|
|
|
, ' ' x ($padding - $key_length) |
|
114
|
|
|
|
|
|
|
, $key; |
|
115
|
|
|
|
|
|
|
|
|
116
|
147
|
|
|
|
|
428
|
my @value = split /\n+/, $value; |
|
117
|
147
|
|
|
|
|
267
|
$result .= shift @value; |
|
118
|
147
|
|
|
|
|
242
|
$result .= "\n"; |
|
119
|
|
|
|
|
|
|
|
|
120
|
147
|
|
|
|
|
392
|
foreach my $value (@value) |
|
121
|
|
|
|
|
|
|
{ |
|
122
|
38
|
|
|
|
|
135
|
$result .= (' ' x ($padding + 2)).$value."\n"; |
|
123
|
|
|
|
|
|
|
} |
|
124
|
|
|
|
|
|
|
} |
|
125
|
42
|
|
|
|
|
731
|
return $result; |
|
126
|
|
|
|
|
|
|
} |
|
127
|
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
1; |