line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package DTL::Fast::Entity; |
2
|
98
|
|
|
98
|
|
37857
|
use strict; use utf8; use warnings FATAL => 'all'; |
|
98
|
|
|
98
|
|
764
|
|
|
98
|
|
|
98
|
|
4144
|
|
|
98
|
|
|
|
|
291
|
|
|
98
|
|
|
|
|
1429
|
|
|
98
|
|
|
|
|
1556
|
|
|
98
|
|
|
|
|
2559
|
|
|
98
|
|
|
|
|
802
|
|
|
98
|
|
|
|
|
4538
|
|
3
|
|
|
|
|
|
|
# prototype for template entity. Handling current line and current template references |
4
|
|
|
|
|
|
|
|
5
|
98
|
|
|
98
|
|
1307
|
use Scalar::Util qw(weaken); |
|
98
|
|
|
|
|
820
|
|
|
98
|
|
|
|
|
9480
|
|
6
|
98
|
|
|
98
|
|
1182
|
use Carp qw(confess); |
|
98
|
|
|
|
|
117
|
|
|
98
|
|
|
|
|
67436
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
sub new |
9
|
|
|
|
|
|
|
{ |
10
|
8071
|
|
|
8071
|
0
|
15730
|
my( $proto, %kwargs ) = @_; |
11
|
|
|
|
|
|
|
|
12
|
8071
|
|
33
|
|
|
19454
|
$proto = ref $proto || $proto; |
13
|
|
|
|
|
|
|
|
14
|
8071
|
|
66
|
|
|
60356
|
$DTL::Fast::Template::CURRENT_TEMPLATE->{'modules'}->{$proto} = $proto->VERSION // DTL::Fast->VERSION; |
15
|
|
|
|
|
|
|
|
16
|
8071
|
|
|
|
|
26727
|
my $self = bless {%kwargs}, $proto; |
17
|
|
|
|
|
|
|
|
18
|
8071
|
|
|
|
|
13683
|
$self->remember_template; |
19
|
|
|
|
|
|
|
|
20
|
8071
|
|
|
|
|
18641
|
return $self; |
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub remember_template |
24
|
|
|
|
|
|
|
{ |
25
|
7109
|
|
|
7109
|
0
|
6062
|
my ($self) = @_; |
26
|
|
|
|
|
|
|
|
27
|
7109
|
|
|
|
|
8630
|
$self->{'_template'} = $DTL::Fast::Template::CURRENT_TEMPLATE; |
28
|
7109
|
|
|
|
|
6317
|
$self->{'_template_line'} = $DTL::Fast::Template::CURRENT_TEMPLATE_LINE; |
29
|
7109
|
|
|
|
|
10698
|
weaken $self->{'_template'}; |
30
|
|
|
|
|
|
|
|
31
|
7109
|
|
|
|
|
6424
|
return $self; |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub get_parse_error |
35
|
|
|
|
|
|
|
{ |
36
|
18
|
|
|
18
|
0
|
45
|
my ($self, $message, @messages) = @_; |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
return $self->compile_error_message( |
39
|
|
|
|
|
|
|
'Parsing error' => $message // 'undef' |
40
|
18
|
|
50
|
|
|
159
|
, 'Template' => $DTL::Fast::Template::CURRENT_TEMPLATE->{'file_path'} |
41
|
|
|
|
|
|
|
, 'Line' => $DTL::Fast::Template::CURRENT_TEMPLATE_LINE |
42
|
|
|
|
|
|
|
, @messages |
43
|
|
|
|
|
|
|
); |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub get_parse_warning |
47
|
|
|
|
|
|
|
{ |
48
|
12
|
|
|
12
|
0
|
20
|
my ($self, $message, @messages) = @_; |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
return $self->compile_error_message( |
51
|
|
|
|
|
|
|
'Parsing warning' => $message // 'undef' |
52
|
12
|
|
50
|
|
|
75
|
, 'Template' => $DTL::Fast::Template::CURRENT_TEMPLATE->{'file_path'} |
53
|
|
|
|
|
|
|
, 'Line' => $DTL::Fast::Template::CURRENT_TEMPLATE_LINE |
54
|
|
|
|
|
|
|
, @messages |
55
|
|
|
|
|
|
|
); |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
sub get_render_error |
59
|
|
|
|
|
|
|
{ |
60
|
12
|
|
|
12
|
0
|
29
|
my ($self, $context, $message, @messages) = @_; |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
my @params = ( |
63
|
|
|
|
|
|
|
'Rendering error' => $message // 'undef' |
64
|
|
|
|
|
|
|
, 'Template' => $self->{'_template'}->{'file_path'} |
65
|
12
|
|
50
|
|
|
77
|
, 'Line' => $self->{'_template_line'} |
66
|
|
|
|
|
|
|
, @messages |
67
|
|
|
|
|
|
|
); |
68
|
|
|
|
|
|
|
|
69
|
12
|
50
|
|
|
|
64
|
confess "No context passed for rendering error generator." unless $context; |
70
|
|
|
|
|
|
|
|
71
|
12
|
100
|
33
|
|
|
85
|
if ( |
|
|
|
66
|
|
|
|
|
72
|
|
|
|
|
|
|
exists $context->{'ns'}->[-1]->{'_dtl_include_path'} |
73
|
|
|
|
|
|
|
and ref $context->{'ns'}->[-1]->{'_dtl_include_path'} eq 'ARRAY' |
74
|
12
|
|
|
|
|
52
|
and scalar @{$context->{'ns'}->[-1]->{'_dtl_include_path'}} > 1 |
75
|
|
|
|
|
|
|
) # has inclusions, appending stack trace |
76
|
|
|
|
|
|
|
{ |
77
|
2
|
|
|
|
|
6
|
push @params, 'Stack trace' => join( "\n", reverse @{$context->{'ns'}->[-1]->{'_dtl_include_path'}}); |
|
2
|
|
|
|
|
11
|
|
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
|
80
|
12
|
|
|
|
|
54
|
return $self->compile_error_message( @params ); |
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
# format error message from key=>val pair |
84
|
|
|
|
|
|
|
sub compile_error_message |
85
|
|
|
|
|
|
|
{ |
86
|
42
|
|
|
42
|
0
|
142
|
my ($self, @messages) = @_; |
87
|
|
|
|
|
|
|
|
88
|
42
|
50
|
|
|
|
149
|
die 'Odd parameters in messages array' |
89
|
|
|
|
|
|
|
if scalar(@messages) % 2; |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
# calculating max padding |
92
|
42
|
|
|
|
|
69
|
my $padding = 0; |
93
|
42
|
|
|
|
|
133
|
for( my $i = 0; $i < scalar @messages; $i += 2 ) |
94
|
|
|
|
|
|
|
{ |
95
|
151
|
|
|
|
|
149
|
my $length = length $messages[$i]; |
96
|
151
|
100
|
|
|
|
412
|
$padding = $length if $length > $padding; |
97
|
|
|
|
|
|
|
} |
98
|
|
|
|
|
|
|
|
99
|
42
|
|
|
|
|
58
|
my $result = ''; |
100
|
42
|
|
|
|
|
93
|
while ( scalar @messages ) |
101
|
|
|
|
|
|
|
{ |
102
|
151
|
|
50
|
|
|
279
|
my $key = shift @messages // 'undef'; |
103
|
151
|
|
50
|
|
|
246
|
my $value = shift @messages // 'undef'; |
104
|
|
|
|
|
|
|
|
105
|
151
|
|
|
|
|
174
|
chomp($value); |
106
|
|
|
|
|
|
|
|
107
|
151
|
|
|
|
|
126
|
my $key_length = length $key; |
108
|
|
|
|
|
|
|
|
109
|
151
|
|
|
|
|
430
|
$result .= sprintf |
110
|
|
|
|
|
|
|
'%s%s: ' |
111
|
|
|
|
|
|
|
, ' ' x ($padding - $key_length) |
112
|
|
|
|
|
|
|
, $key; |
113
|
|
|
|
|
|
|
|
114
|
151
|
|
|
|
|
356
|
my @value = split /\n+/, $value; |
115
|
151
|
|
|
|
|
188
|
$result .= shift @value; |
116
|
151
|
|
|
|
|
166
|
$result .= "\n"; |
117
|
|
|
|
|
|
|
|
118
|
151
|
|
|
|
|
372
|
foreach my $value (@value) |
119
|
|
|
|
|
|
|
{ |
120
|
38
|
|
|
|
|
114
|
$result .= (' ' x ($padding + 2)).$value."\n"; |
121
|
|
|
|
|
|
|
} |
122
|
|
|
|
|
|
|
} |
123
|
42
|
|
|
|
|
1073
|
return $result; |
124
|
|
|
|
|
|
|
} |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
1; |