line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package DTL::Fast::Filter::Center; |
2
|
4
|
|
|
4
|
|
1588
|
use strict; use utf8; use warnings FATAL => 'all'; |
|
4
|
|
|
4
|
|
5
|
|
|
4
|
|
|
4
|
|
85
|
|
|
4
|
|
|
|
|
12
|
|
|
4
|
|
|
|
|
4
|
|
|
4
|
|
|
|
|
17
|
|
|
4
|
|
|
|
|
66
|
|
|
4
|
|
|
|
|
4
|
|
|
4
|
|
|
|
|
116
|
|
3
|
4
|
|
|
4
|
|
14
|
use parent 'DTL::Fast::Filter'; |
|
4
|
|
|
|
|
5
|
|
|
4
|
|
|
|
|
18
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
$DTL::Fast::FILTER_HANDLERS{'center'} = __PACKAGE__; |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
#@Override |
8
|
|
|
|
|
|
|
sub parse_parameters |
9
|
|
|
|
|
|
|
{ |
10
|
8
|
|
|
8
|
0
|
8
|
my $self = shift; |
11
|
|
|
|
|
|
|
die $self->get_parse_error("no width specified for adjusting") |
12
|
8
|
50
|
|
|
|
7
|
if not scalar @{$self->{'parameter'}}; |
|
8
|
|
|
|
|
18
|
|
13
|
8
|
|
|
|
|
11
|
$self->{'width'} = $self->{'parameter'}->[0]; |
14
|
8
|
|
|
|
|
18
|
return $self; |
15
|
|
|
|
|
|
|
} |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
#@Override |
18
|
|
|
|
|
|
|
sub filter |
19
|
|
|
|
|
|
|
{ |
20
|
8
|
|
|
8
|
0
|
10
|
my ($self, $filter_manager, $value, $context) = @_; |
21
|
|
|
|
|
|
|
|
22
|
8
|
|
|
|
|
30
|
my $width = $self->{'width'}->render($context); |
23
|
|
|
|
|
|
|
|
24
|
8
|
50
|
|
|
|
37
|
if( $width =~ /^\d+$/ ) |
25
|
|
|
|
|
|
|
{ |
26
|
8
|
|
|
|
|
14
|
my $adjustment = ($width - length $value); |
27
|
8
|
50
|
|
|
|
14
|
if( $adjustment > 0 ) |
28
|
|
|
|
|
|
|
{ |
29
|
8
|
|
|
|
|
17
|
$value = $self->adjust($value, $adjustment); |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
else |
33
|
|
|
|
|
|
|
{ |
34
|
0
|
|
|
|
|
0
|
die $self->get_render_error("Argument must be a positive number, not '$width'"); |
35
|
|
|
|
|
|
|
} |
36
|
8
|
|
|
|
|
22
|
return $value; |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
sub adjust |
40
|
|
|
|
|
|
|
{ |
41
|
4
|
|
|
4
|
0
|
3
|
my ($self, $value, $adjustment) = @_; |
42
|
4
|
|
|
|
|
16
|
return (' 'x int($adjustment/2)).$value; |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
1; |