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