line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package DTL::Fast::Filter::Floatformat; |
2
|
2
|
|
|
2
|
|
704
|
use strict; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
44
|
|
3
|
2
|
|
|
2
|
|
8
|
use utf8; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
8
|
|
4
|
2
|
|
|
2
|
|
39
|
use warnings FATAL => 'all'; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
78
|
|
5
|
2
|
|
|
2
|
|
9
|
use parent 'DTL::Fast::Filter'; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
9
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
$DTL::Fast::FILTER_HANDLERS{floatformat} = __PACKAGE__; |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
#@Override |
10
|
|
|
|
|
|
|
sub parse_parameters |
11
|
|
|
|
|
|
|
{ |
12
|
12
|
|
|
12
|
0
|
20
|
my $self = shift; |
13
|
|
|
|
|
|
|
$self->{digits} = $self->{parameter}->[0] |
14
|
12
|
100
|
|
|
|
17
|
if (scalar @{$self->{parameter}}); |
|
12
|
|
|
|
|
31
|
|
15
|
12
|
|
|
|
|
33
|
return $self; |
16
|
|
|
|
|
|
|
} |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
#@Override |
19
|
|
|
|
|
|
|
sub filter |
20
|
|
|
|
|
|
|
{ |
21
|
12
|
|
|
12
|
0
|
17
|
my $self = shift; # self |
22
|
12
|
|
|
|
|
16
|
shift; # filter_manager |
23
|
12
|
|
|
|
|
20
|
my $value = shift; |
24
|
12
|
|
|
|
|
16
|
my $context = shift; |
25
|
|
|
|
|
|
|
|
26
|
12
|
100
|
|
|
|
32
|
my $digits = defined $self->{digits} ? $self->{digits}->render($context) : undef; |
27
|
|
|
|
|
|
|
|
28
|
12
|
100
|
66
|
|
|
62
|
if ( |
29
|
|
|
|
|
|
|
defined $digits |
30
|
|
|
|
|
|
|
and $digits =~ /^\d+$/ |
31
|
|
|
|
|
|
|
) |
32
|
|
|
|
|
|
|
{ |
33
|
8
|
|
|
|
|
52
|
$value = sprintf "%.0${digits}f", $value; |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
12
|
|
|
|
|
35
|
return $value; |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
1; |