line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package DTL::Fast::Filter::Stringformat; |
2
|
2
|
|
|
2
|
|
869
|
use strict; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
48
|
|
3
|
2
|
|
|
2
|
|
10
|
use utf8; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
11
|
|
4
|
2
|
|
|
2
|
|
43
|
use warnings FATAL => 'all'; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
62
|
|
5
|
2
|
|
|
2
|
|
9
|
use parent 'DTL::Fast::Filter'; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
10
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
$DTL::Fast::FILTER_HANDLERS{stringformat} = __PACKAGE__; |
8
|
|
|
|
|
|
|
|
9
|
2
|
|
|
2
|
|
135
|
use DTL::Fast::Variable; |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
350
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
#@Override |
12
|
|
|
|
|
|
|
sub parse_parameters |
13
|
|
|
|
|
|
|
{ |
14
|
3
|
|
|
3
|
0
|
8
|
my $self = shift; |
15
|
|
|
|
|
|
|
die $self->get_parse_error("no format string specified") |
16
|
3
|
50
|
|
|
|
7
|
if (not scalar @{$self->{parameter}}); |
|
3
|
|
|
|
|
12
|
|
17
|
3
|
|
|
|
|
9
|
$self->{format} = $self->{parameter}->[0]; |
18
|
3
|
|
|
|
|
12
|
return $self; |
19
|
|
|
|
|
|
|
} |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
#@Override |
22
|
|
|
|
|
|
|
sub filter |
23
|
|
|
|
|
|
|
{ |
24
|
3
|
|
|
3
|
0
|
10
|
my ($self, $filter_manager, $value, $context ) = @_; |
25
|
|
|
|
|
|
|
|
26
|
3
|
|
|
|
|
16
|
my $format = $self->{format}->render($context); |
27
|
|
|
|
|
|
|
|
28
|
3
|
50
|
|
|
|
15
|
die $self->get_render_error($context, 'unable to format string with undef value') |
29
|
|
|
|
|
|
|
if (not defined $value); |
30
|
|
|
|
|
|
|
|
31
|
3
|
50
|
|
|
|
10
|
die $self->get_render_error($context, 'unable to format string with undef format') |
32
|
|
|
|
|
|
|
if (not defined $format); |
33
|
|
|
|
|
|
|
|
34
|
3
|
|
|
|
|
46
|
return sprintf '%'.$format, $value; |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
1; |