line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
#============================================================= -*-Perl-*- |
2
|
|
|
|
|
|
|
# |
3
|
|
|
|
|
|
|
# Template::Plugin::Format |
4
|
|
|
|
|
|
|
# |
5
|
|
|
|
|
|
|
# DESCRIPTION |
6
|
|
|
|
|
|
|
# |
7
|
|
|
|
|
|
|
# Simple Template Toolkit Plugin which creates formatting functions. |
8
|
|
|
|
|
|
|
# |
9
|
|
|
|
|
|
|
# AUTHOR |
10
|
|
|
|
|
|
|
# Andy Wardley |
11
|
|
|
|
|
|
|
# |
12
|
|
|
|
|
|
|
# COPYRIGHT |
13
|
|
|
|
|
|
|
# Copyright (C) 1996-2007 Andy Wardley. All Rights Reserved. |
14
|
|
|
|
|
|
|
# |
15
|
|
|
|
|
|
|
# This module is free software; you can redistribute it and/or |
16
|
|
|
|
|
|
|
# modify it under the same terms as Perl itself. |
17
|
|
|
|
|
|
|
# |
18
|
|
|
|
|
|
|
#============================================================================ |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
package Template::Plugin::Format; |
21
|
|
|
|
|
|
|
|
22
|
2
|
|
|
2
|
|
10
|
use strict; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
72
|
|
23
|
2
|
|
|
2
|
|
10
|
use warnings; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
75
|
|
24
|
2
|
|
|
2
|
|
9
|
use base 'Template::Plugin'; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
821
|
|
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
our $VERSION = 2.70; |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub new { |
30
|
7
|
|
|
7
|
1
|
15
|
my ($class, $context, $format) = @_;; |
31
|
7
|
100
|
|
|
|
31
|
return defined $format |
32
|
|
|
|
|
|
|
? make_formatter($format) |
33
|
|
|
|
|
|
|
: \&make_formatter; |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub make_formatter { |
38
|
8
|
|
|
8
|
0
|
15
|
my $format = shift; |
39
|
8
|
50
|
|
|
|
19
|
$format = '%s' unless defined $format; |
40
|
|
|
|
|
|
|
return sub { |
41
|
18
|
|
|
18
|
|
234
|
my @args = @_; |
42
|
18
|
100
|
|
|
|
42
|
push(@args, '') unless @args; |
43
|
18
|
|
|
|
|
97
|
return sprintf($format, @args); |
44
|
|
|
|
|
|
|
} |
45
|
8
|
|
|
|
|
71
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
1; |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
__END__ |