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