line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package DTL::Fast::Tag::Block; |
2
|
2
|
|
|
2
|
|
803
|
use strict; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
48
|
|
3
|
2
|
|
|
2
|
|
9
|
use utf8; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
8
|
|
4
|
2
|
|
|
2
|
|
41
|
use warnings FATAL => 'all'; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
53
|
|
5
|
2
|
|
|
2
|
|
9
|
use parent 'DTL::Fast::Tag'; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
8
|
|
6
|
|
|
|
|
|
|
|
7
|
2
|
|
|
2
|
|
106
|
use Data::Dumper; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
620
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our $VERSION = '1.00'; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
$DTL::Fast::TAG_HANDLERS{block} = __PACKAGE__; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
#@Override |
14
|
27
|
|
|
27
|
0
|
76
|
sub get_close_tag {return 'endblock';} |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
#@Override |
17
|
|
|
|
|
|
|
sub parse_parameters |
18
|
|
|
|
|
|
|
{ |
19
|
26
|
|
|
26
|
0
|
44
|
my ( $self ) = @_; |
20
|
|
|
|
|
|
|
|
21
|
26
|
|
|
|
|
49
|
$self->{block_name} = $self->{parameter}; |
22
|
|
|
|
|
|
|
|
23
|
26
|
100
|
|
|
|
63
|
die $self->get_parse_error("no name specified in the block tag") if (not $self->{block_name}); |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
# registering block within template |
26
|
25
|
100
|
|
|
|
61
|
if (exists $DTL::Fast::Template::CURRENT_TEMPLATE->{blocks}->{$self->{block_name}}) |
27
|
|
|
|
|
|
|
{ |
28
|
|
|
|
|
|
|
die $self->get_parse_error( |
29
|
|
|
|
|
|
|
sprintf( |
30
|
|
|
|
|
|
|
"block name `%s` must be unique in the template" |
31
|
|
|
|
|
|
|
, $self->{block_name} |
32
|
|
|
|
|
|
|
) |
33
|
|
|
|
|
|
|
, Reason => sprintf( |
34
|
|
|
|
|
|
|
'block `%s` was already defined at line %s' |
35
|
|
|
|
|
|
|
, $self->{block_name} |
36
|
|
|
|
|
|
|
, $DTL::Fast::Template::CURRENT_TEMPLATE->{blocks}->{$self->{block_name}}->{_template_line} |
37
|
|
|
|
|
|
|
) |
38
|
1
|
|
|
|
|
7
|
); |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
else |
41
|
|
|
|
|
|
|
{ |
42
|
24
|
|
|
|
|
55
|
$DTL::Fast::Template::CURRENT_TEMPLATE->{blocks}->{$self->{block_name}} = $self; |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
24
|
|
|
|
|
46
|
return $self; |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
#@Override |
49
|
|
|
|
|
|
|
sub render |
50
|
|
|
|
|
|
|
{ |
51
|
24
|
|
|
24
|
0
|
43
|
my ( $self, $context ) = @_; |
52
|
|
|
|
|
|
|
|
53
|
24
|
|
|
|
|
38
|
my $result; |
54
|
|
|
|
|
|
|
|
55
|
24
|
|
|
|
|
64
|
$context->push_scope(); |
56
|
24
|
|
|
|
|
45
|
my $ns = $context->{ns}->[- 1]; |
57
|
|
|
|
|
|
|
|
58
|
24
|
|
|
|
|
37
|
$ns->{_dtl_rendering_block} = $self; |
59
|
|
|
|
|
|
|
|
60
|
24
|
100
|
|
|
|
52
|
if ($ns->{_dtl_descendants}) |
61
|
|
|
|
|
|
|
{ |
62
|
|
|
|
|
|
|
# template with inheritance |
63
|
16
|
|
|
|
|
22
|
foreach my $descendant (@{$ns->{_dtl_descendants}}) |
|
16
|
|
|
|
|
30
|
|
64
|
|
|
|
|
|
|
{ |
65
|
24
|
50
|
|
|
|
80
|
if ($descendant == $self) |
|
|
100
|
|
|
|
|
|
66
|
|
|
|
|
|
|
{ |
67
|
0
|
|
|
|
|
0
|
$result = $self->SUPER::render($context); |
68
|
0
|
|
|
|
|
0
|
last; |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
elsif ($descendant->{blocks}->{$self->{block_name}}) |
71
|
|
|
|
|
|
|
{ |
72
|
16
|
|
|
|
|
23
|
$ns->{_dtl_rendering_template} = $descendant; |
73
|
16
|
|
|
|
|
43
|
$result = $descendant->{blocks}->{$self->{block_name}}->SUPER::render($context); |
74
|
16
|
|
|
|
|
31
|
last; |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
else |
79
|
|
|
|
|
|
|
{ |
80
|
|
|
|
|
|
|
# simple template |
81
|
8
|
|
|
|
|
29
|
$result = $self->SUPER::render($context); |
82
|
|
|
|
|
|
|
} |
83
|
18
|
|
|
|
|
49
|
$context->pop_scope(); |
84
|
|
|
|
|
|
|
|
85
|
18
|
|
|
|
|
63
|
return $result; |
86
|
|
|
|
|
|
|
} |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
1; |