| 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 | 2 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 23 | 2 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 24 | 2 | ▶ | use base 'Template::Plugin'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 25 | |||||||||||
| 26 | 2 | our $VERSION = '3.100'; | |||||||||
| 27 | |||||||||||
| 28 | |||||||||||
| 29 | sub new { | ||||||||||
| 30 | 7 | ▶ | my ($class, $context, $format) = @_;; | ||||||||
|
Subroutine
new: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||
| 31 | 7 | ▶ | return defined $format | ||||||||
|
Branch: 1 branch
| |||||||||||
| 32 | ? make_formatter($format) | ||||||||||
| 33 | : \&make_formatter; | ||||||||||
| 34 | } | ||||||||||
| 35 | |||||||||||
| 36 | |||||||||||
| 37 | sub make_formatter { | ||||||||||
| 38 | 8 | ▶ | my $format = shift; | ||||||||
|
Subroutine
make_formatter: called CC=2 SCAR=7.0
Pod
undocumented
| |||||||||||
| 39 | 8 | ▶ | $format = '%s' unless defined $format; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 40 | return sub { | ||||||||||
| 41 | 18 | ▶ | my @args = @_; | ||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
| |||||||||||
| 42 | 18 | ▶ | push(@args, '') unless @args; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 43 | 18 | return sprintf($format, @args); | |||||||||
| 44 | } | ||||||||||
| 45 | 8 | } | |||||||||
| 46 | |||||||||||
| 47 | |||||||||||
| 48 | 2 | 1; | |||||||||
| 49 | |||||||||||
| 50 | __END__ | ||||||||||