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