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
|
|
12
|
use strict; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
85
|
|
23
|
2
|
|
|
2
|
|
12
|
use warnings; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
82
|
|
24
|
2
|
|
|
2
|
|
12
|
use base 'Template::Plugin'; |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
907
|
|
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
our $VERSION = 2.70; |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub new { |
30
|
7
|
|
|
7
|
1
|
28
|
my ($class, $context, $format) = @_;; |
31
|
7
|
100
|
|
|
|
33
|
return defined $format |
32
|
|
|
|
|
|
|
? make_formatter($format) |
33
|
|
|
|
|
|
|
: \&make_formatter; |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub make_formatter { |
38
|
8
|
|
|
8
|
0
|
13
|
my $format = shift; |
39
|
8
|
50
|
|
|
|
16
|
$format = '%s' unless defined $format; |
40
|
|
|
|
|
|
|
return sub { |
41
|
18
|
|
|
18
|
|
213
|
my @args = @_; |
42
|
18
|
100
|
|
|
|
39
|
push(@args, '') unless @args; |
43
|
18
|
|
|
|
|
91
|
return sprintf($format, @args); |
44
|
|
|
|
|
|
|
} |
45
|
8
|
|
|
|
|
70
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
1; |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
__END__ |