line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package DTL::Fast::Tag::Cycle; |
2
|
2
|
|
|
2
|
|
747
|
use strict; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
46
|
|
3
|
2
|
|
|
2
|
|
9
|
use utf8; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
10
|
|
4
|
2
|
|
|
2
|
|
39
|
use warnings FATAL => 'all'; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
58
|
|
5
|
2
|
|
|
2
|
|
8
|
use parent 'DTL::Fast::Tag::Simple'; |
|
2
|
|
|
|
|
7
|
|
|
2
|
|
|
|
|
10
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
$DTL::Fast::TAG_HANDLERS{cycle} = __PACKAGE__; |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
#@Override |
10
|
|
|
|
|
|
|
sub parse_parameters |
11
|
|
|
|
|
|
|
{ |
12
|
11
|
|
|
11
|
0
|
18
|
my $self = shift; |
13
|
|
|
|
|
|
|
|
14
|
11
|
|
|
|
|
115
|
$self->{parameter} =~ /^\s*(.+?)\s*(?:as (.+?)\s*(silent)?)?\s*$/; |
15
|
11
|
|
50
|
|
|
81
|
@{$self}{'source', 'destination', 'silent', 'sources', 'current_sources'} = ($1 // '', $2 // '', $3 // '', [ ], |
|
11
|
|
100
|
|
|
38
|
|
|
|
|
100
|
|
|
|
|
16
|
|
|
|
|
|
|
[ ]); |
17
|
11
|
|
|
|
|
38
|
$self->{sources} = $self->parse_sources($self->{source}); |
18
|
|
|
|
|
|
|
|
19
|
11
|
|
|
|
|
25
|
return $self; |
20
|
|
|
|
|
|
|
} |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
#@Override |
23
|
|
|
|
|
|
|
sub render |
24
|
|
|
|
|
|
|
{ |
25
|
53
|
|
|
53
|
0
|
93
|
my ( $self, $context, $global_safe) = @_; |
26
|
53
|
|
|
|
|
73
|
my $result = ''; |
27
|
|
|
|
|
|
|
|
28
|
53
|
|
|
|
|
94
|
my $source = $self->get_next_source(); |
29
|
53
|
|
|
|
|
121
|
my $current_value = $source->render($context, $global_safe); |
30
|
|
|
|
|
|
|
|
31
|
53
|
100
|
|
|
|
119
|
if (not $self->{silent}) |
32
|
|
|
|
|
|
|
{ |
33
|
43
|
|
|
|
|
64
|
$result = $current_value; |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
53
|
100
|
|
|
|
148
|
if ($self->{destination}) |
37
|
|
|
|
|
|
|
{ |
38
|
20
|
|
|
|
|
46
|
$context->set( $self->{destination} => $current_value ); |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
53
|
|
|
|
|
165
|
return $result; |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
sub get_next_source |
45
|
|
|
|
|
|
|
{ |
46
|
53
|
|
|
53
|
0
|
73
|
my $self = shift; |
47
|
|
|
|
|
|
|
|
48
|
53
|
100
|
|
|
|
65
|
if (not scalar @{$self->{current_sources}}) # populate for current cycle |
|
53
|
|
|
|
|
119
|
|
49
|
|
|
|
|
|
|
{ |
50
|
18
|
|
|
|
|
23
|
push @{$self->{current_sources}}, @{$self->{sources}}; |
|
18
|
|
|
|
|
31
|
|
|
18
|
|
|
|
|
30
|
|
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
53
|
|
|
|
|
81
|
return shift @{$self->{current_sources}}; |
|
53
|
|
|
|
|
86
|
|
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
1; |