line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package DTL::Fast::Filter::Split; |
2
|
2
|
|
|
2
|
|
824
|
use strict; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
47
|
|
3
|
2
|
|
|
2
|
|
9
|
use utf8; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
11
|
|
4
|
2
|
|
|
2
|
|
40
|
use warnings FATAL => 'all'; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
70
|
|
5
|
2
|
|
|
2
|
|
9
|
use parent 'DTL::Fast::Filter'; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
11
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
$DTL::Fast::FILTER_HANDLERS{split} = __PACKAGE__; |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
#@Override |
10
|
|
|
|
|
|
|
sub parse_parameters |
11
|
|
|
|
|
|
|
{ |
12
|
1
|
|
|
1
|
0
|
3
|
my $self = shift; |
13
|
|
|
|
|
|
|
die $self->get_parse_error("no split pattern specified") |
14
|
1
|
50
|
|
|
|
3
|
if (not scalar @{$self->{parameter}}); |
|
1
|
|
|
|
|
7
|
|
15
|
1
|
|
|
|
|
3
|
$self->{pattern} = $self->{parameter}->[0]; |
16
|
1
|
|
|
|
|
7
|
return $self; |
17
|
|
|
|
|
|
|
} |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
#@Override |
20
|
|
|
|
|
|
|
sub filter |
21
|
|
|
|
|
|
|
{ |
22
|
1
|
|
|
1
|
0
|
2
|
my ($self, $filter_manager, $value, $context ) = @_; |
23
|
|
|
|
|
|
|
|
24
|
1
|
|
|
|
|
7
|
my $pattern = $self->{pattern}->render($context); |
25
|
|
|
|
|
|
|
|
26
|
1
|
50
|
|
|
|
4
|
die $self->get_render_error("splitting pattern must be defined and not empty") |
27
|
|
|
|
|
|
|
if (not $pattern); |
28
|
|
|
|
|
|
|
|
29
|
1
|
|
50
|
|
|
17
|
$value = [ split /$pattern/si, $value // '' ]; |
30
|
|
|
|
|
|
|
|
31
|
1
|
|
|
|
|
4
|
return $value; |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
1; |