| 1 | package DTL::Fast::Filter::Stringformat; | ||||||||||
| 2 | 2 | ▶ | use strict; use utf8; use warnings FATAL => 'all'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 3 | 2 | ▶ | use parent 'DTL::Fast::Filter'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | |||||||||||
| 5 | 2 | $DTL::Fast::FILTER_HANDLERS{'stringformat'} = __PACKAGE__; | |||||||||
| 6 | |||||||||||
| 7 | 2 | ▶ | use DTL::Fast::Variable; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | |||||||||||
| 9 | #@Override | ||||||||||
| 10 | sub parse_parameters | ||||||||||
| 11 | { | ||||||||||
| 12 | 3 | ▶ | my $self = shift; | ||||||||
|
Subroutine
parse_parameters: called CC=2 SCAR=7.0
Pod
undocumented
| |||||||||||
| 13 | die $self->get_parse_error("no format string specified") | ||||||||||
| 14 | 3 | ▶ | if not scalar @{$self->{'parameter'}}; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 15 | 3 | $self->{'format'} = $self->{'parameter'}->[0]; | |||||||||
| 16 | 3 | return $self; | |||||||||
| 17 | } | ||||||||||
| 18 | |||||||||||
| 19 | #@Override | ||||||||||
| 20 | sub filter | ||||||||||
| 21 | { | ||||||||||
| 22 | 3 | ▶ | my($self, $filter_manager, $value, $context ) = @_; | ||||||||
|
Subroutine
filter: called CC=3 SCAR=11.3
Pod
undocumented
| |||||||||||
| 23 | |||||||||||
| 24 | 3 | my $format = $self->{'format'}->render($context); | |||||||||
| 25 | |||||||||||
| 26 | 3 | ▶ | die $self->get_render_error($context, 'unable to format string with undef value') | ||||||||
|
Branch: 1 branch
| |||||||||||
| 27 | if not defined $value; | ||||||||||
| 28 | |||||||||||
| 29 | 3 | ▶ | die $self->get_render_error($context, 'unable to format string with undef format') | ||||||||
|
Branch: 1 branch
| |||||||||||
| 30 | if not defined $format; | ||||||||||
| 31 | |||||||||||
| 32 | 3 | return sprintf '%'.$format, $value; | |||||||||
| 33 | } | ||||||||||
| 34 | |||||||||||
| 35 | 2 | 1; | |||||||||