line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package HTML::Template::Compiled::Plugin::Sprintf; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# ABSTRACT: Use sprintf in HTML::Template::Compiled templates |
4
|
|
|
|
|
|
|
|
5
|
3
|
|
|
3
|
|
3161
|
use strict; |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
91
|
|
6
|
3
|
|
|
3
|
|
15
|
use warnings; |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
83
|
|
7
|
|
|
|
|
|
|
|
8
|
3
|
|
|
3
|
|
18
|
use HTML::Template::Compiled; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
22
|
|
9
|
|
|
|
|
|
|
HTML::Template::Compiled->register(__PACKAGE__); |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
our $VERSION = '0.03'; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub register{ |
14
|
3
|
|
|
3
|
1
|
56
|
my ($class) = @_; |
15
|
3
|
|
|
|
|
19
|
my %plugs = ( |
16
|
|
|
|
|
|
|
escape => { |
17
|
|
|
|
|
|
|
SPRINTF_30_LEFT => \&escape_sprintf_30_left, |
18
|
|
|
|
|
|
|
SPRINTF_6_RIGHT => \&escape_sprintf_6_right, |
19
|
|
|
|
|
|
|
SPRINTF_8_RIGHT => \&escape_sprintf_8_right, |
20
|
|
|
|
|
|
|
}, |
21
|
|
|
|
|
|
|
); |
22
|
|
|
|
|
|
|
|
23
|
3
|
|
|
|
|
11
|
return \%plugs; |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub escape_sprintf_30_left { |
27
|
2
|
|
|
2
|
1
|
3164
|
my ($escaped) = @_; |
28
|
2
|
100
|
|
|
|
28
|
return unless defined $escaped; |
29
|
|
|
|
|
|
|
|
30
|
1
|
|
|
|
|
5
|
my $string = sprintf "%-30s", $escaped; |
31
|
|
|
|
|
|
|
|
32
|
1
|
|
|
|
|
22
|
return $string; |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub escape_sprintf_6_right { |
36
|
2
|
|
|
2
|
1
|
3112
|
my ($escaped) = @_; |
37
|
2
|
100
|
|
|
|
26
|
return unless defined $escaped; |
38
|
|
|
|
|
|
|
|
39
|
1
|
|
|
|
|
5
|
my $string = sprintf "%6s", $escaped; |
40
|
|
|
|
|
|
|
|
41
|
1
|
|
|
|
|
22
|
return $string; |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
sub escape_sprintf_8_right { |
45
|
2
|
|
|
2
|
1
|
3157
|
my ($escaped) = @_; |
46
|
2
|
100
|
|
|
|
26
|
return unless defined $escaped; |
47
|
|
|
|
|
|
|
|
48
|
1
|
|
|
|
|
4
|
my $string = sprintf "%8s", $escaped; |
49
|
|
|
|
|
|
|
|
50
|
1
|
|
|
|
|
22
|
return $string; |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
1; |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
__END__ |