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