line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package DTL::Fast::Filter::Join; |
2
|
8
|
|
|
8
|
|
3186
|
use strict; |
|
8
|
|
|
|
|
17
|
|
|
8
|
|
|
|
|
186
|
|
3
|
8
|
|
|
8
|
|
35
|
use utf8; |
|
8
|
|
|
|
|
16
|
|
|
8
|
|
|
|
|
37
|
|
4
|
8
|
|
|
8
|
|
162
|
use warnings FATAL => 'all'; |
|
8
|
|
|
|
|
14
|
|
|
8
|
|
|
|
|
245
|
|
5
|
8
|
|
|
8
|
|
39
|
use parent 'DTL::Fast::Filter'; |
|
8
|
|
|
|
|
15
|
|
|
8
|
|
|
|
|
40
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
$DTL::Fast::FILTER_HANDLERS{join} = __PACKAGE__; |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
#@Override |
10
|
|
|
|
|
|
|
sub parse_parameters |
11
|
|
|
|
|
|
|
{ |
12
|
39
|
|
|
39
|
0
|
71
|
my ( $self ) = @_; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
die $self->get_parse_error("no separator passed to the join filter") |
15
|
|
|
|
|
|
|
if ( |
16
|
|
|
|
|
|
|
ref $self->{parameter} ne 'ARRAY' |
17
|
39
|
50
|
33
|
|
|
115
|
or not scalar @{$self->{parameter}} |
|
39
|
|
|
|
|
137
|
|
18
|
|
|
|
|
|
|
); |
19
|
|
|
|
|
|
|
|
20
|
39
|
|
|
|
|
95
|
$self->{sep} = $self->{parameter}->[0]; |
21
|
|
|
|
|
|
|
|
22
|
39
|
|
|
|
|
113
|
return $self; |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
#@Override |
26
|
|
|
|
|
|
|
sub filter |
27
|
|
|
|
|
|
|
{ |
28
|
34
|
|
|
34
|
0
|
67
|
my ( $self, $filter_manager, $value, $context ) = @_; |
29
|
|
|
|
|
|
|
|
30
|
34
|
|
|
|
|
64
|
my $value_type = ref $value; |
31
|
34
|
|
|
|
|
49
|
my $result = undef; |
32
|
34
|
|
|
|
|
105
|
my $separator = $self->{sep}->render($context, 1); |
33
|
|
|
|
|
|
|
|
34
|
34
|
|
|
|
|
71
|
my @source = (); |
35
|
34
|
100
|
|
|
|
91
|
if ($value_type eq 'HASH') |
|
|
100
|
|
|
|
|
|
36
|
|
|
|
|
|
|
{ |
37
|
1
|
|
|
|
|
4
|
@source = (%$value); |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
elsif ($value_type eq 'ARRAY') |
40
|
|
|
|
|
|
|
{ |
41
|
32
|
|
|
|
|
85
|
@source = @$value; |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
else |
44
|
|
|
|
|
|
|
{ |
45
|
1
|
|
50
|
|
|
12
|
die $self->get_render_error( |
46
|
|
|
|
|
|
|
$context, |
47
|
|
|
|
|
|
|
sprintf( "Unable to apply join filter to the %s value" |
48
|
|
|
|
|
|
|
, $value_type || 'SCALAR' |
49
|
|
|
|
|
|
|
) |
50
|
|
|
|
|
|
|
); |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
33
|
100
|
|
|
|
80
|
if ($filter_manager->{safeseq}) |
54
|
|
|
|
|
|
|
{ |
55
|
|
|
|
|
|
|
$separator = DTL::Fast::html_protect($separator) |
56
|
2
|
100
|
|
|
|
9
|
if (not $context->{ns}->[- 1]->{_dtl_safe}); |
57
|
|
|
|
|
|
|
|
58
|
2
|
|
|
|
|
5
|
$filter_manager->{safe} = 1; |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|
61
|
33
|
|
|
|
|
151
|
return join $separator, @source; |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
1; |