| 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.106'; | |||||||||||
| 27 | |||||||||||||
| 28 | |||||||||||||
| 29 | 7 | ▶ | sub new { | ||||||||||
|
Subroutine
new: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||
| 30 | 7 | my ($class, $context, $format) = @_;; | |||||||||||
| 31 | 7 | ▶ | return defined $format | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 32 | ? make_formatter($format) | ||||||||||||
| 33 | : \&make_formatter; | ||||||||||||
| 34 | } | ||||||||||||
| 35 | |||||||||||||
| 36 | |||||||||||||
| 37 | 8 | ▶ | sub make_formatter { | ||||||||||
|
Subroutine
make_formatter: called CC=2 SCAR=7.0
Pod
undocumented
| |||||||||||||
| 38 | 8 | ▶ | my $format = shift // '%s'; | ||||||||||
|
Condition50%1/2
shift() // "%s"
MC/DC0%0/1
shift() // "%s"
shift()
Truth table50%1/2
A
A= shift()
| |||||||||||||
| 39 | 18 | ▶ | return sub { | ||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
| |||||||||||||
| 40 | 18 | my @args = @_; | |||||||||||
| 41 | 18 | ▶ | push(@args, '') unless @args; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 42 | 18 | return sprintf($format, @args); | |||||||||||
| 43 | } | ||||||||||||
| 44 | 8 | } | |||||||||||
| 45 | |||||||||||||
| 46 | |||||||||||||
| 47 | 2 | 1; | |||||||||||
| 48 | |||||||||||||
| 49 | __END__ | ||||||||||||