blib/lib/Template/Plugin/Format.pm untested

filter: Statementstmt 0.0% 0 / 18 Branchbran 0.0% 0 / 4 Conditioncond 0.0% 0 / 2 MC/DCmcdc n/a Subroutinesub 0.0% 0 / 5 Podpod 0.0% 0 / 2 totaltotal 0.0% 0 / 31 CC 3 SCAR 14.6
CC
3
Cov
0%
new
6.0
make_formatter
6.0
BEGIN
2.0
CRAP 4.3
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 <abw@wardley.org>
11 #
12 # COPYRIGHT
13 # Copyright (C) 1996-2022 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 use strict;
23 use warnings;
24 use base 'Template::Plugin';
25  
26 our $VERSION = '3.105';
27  
28  
29 sub new {
30 my ($class, $context, $format) = @_;;
31 return defined $format
32 ? make_formatter($format)
33 : \&make_formatter;
34 }
35  
36  
37 sub make_formatter {
38 my $format = shift // '%s';
39 return sub {
40 my @args = @_;
41 push(@args, '') unless @args;
42 return sprintf($format, @args);
43 }
44 }
45  
46  
47 1;
48  
49 __END__