| 1 | #============================================================= -*-Perl-*- | ||||||||||||
| 2 | # | ||||||||||||
| 3 | # Template::Plugin::Wrap | ||||||||||||
| 4 | # | ||||||||||||
| 5 | # DESCRIPTION | ||||||||||||
| 6 | # Plugin for wrapping text via the Text::Wrap module. | ||||||||||||
| 7 | # | ||||||||||||
| 8 | # AUTHOR | ||||||||||||
| 9 | # Andy Wardley <abw@wardley.org> | ||||||||||||
| 10 | # | ||||||||||||
| 11 | # COPYRIGHT | ||||||||||||
| 12 | # Copyright (C) 1996-2022 Andy Wardley. All Rights Reserved. | ||||||||||||
| 13 | # | ||||||||||||
| 14 | # This module is free software; you can redistribute it and/or | ||||||||||||
| 15 | # modify it under the same terms as Perl itself. | ||||||||||||
| 16 | # | ||||||||||||
| 17 | #============================================================================ | ||||||||||||
| 18 | |||||||||||||
| 19 | package Template::Plugin::Wrap; | ||||||||||||
| 20 | |||||||||||||
| 21 | 1 | ▶ | use strict; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 22 | 1 | ▶ | use warnings; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 23 | 1 | ▶ | use base 'Template::Plugin'; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 24 | 1 | ▶ | use Text::Wrap; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 25 | |||||||||||||
| 26 | 1 | our $VERSION = '3.106'; | |||||||||||
| 27 | |||||||||||||
| 28 | 3 | ▶ | sub new { | ||||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||
| 29 | 3 | my ($class, $context, $format) = @_;; | |||||||||||
| 30 | 3 | $context->define_filter('wrap', [ \&wrap_filter_factory => 1 ]); | |||||||||||
| 31 | 3 | return \&tt_wrap; | |||||||||||
| 32 | } | ||||||||||||
| 33 | |||||||||||||
| 34 | 6 | ▶ | sub tt_wrap { | ||||||||||
|
Subroutine
tt_wrap: called CC=4 SCAR=13.9
Pod
undocumented
| |||||||||||||
| 35 | 6 | my $text = shift; | |||||||||||
| 36 | 6 | ▶ | my $width = shift || 72; | ||||||||||
|
Condition100%2/2
shift() || 72
MC/DC100%1/1
shift() || 72
shift()
Truth table100%2/2
A
A= shift()
| |||||||||||||
| 37 | 6 | ▶ | my $itab = shift // ''; | ||||||||||
|
Condition100%2/2
shift() // ""
MC/DC100%1/1
shift() // ""
shift()
Truth table100%2/2
A
A= shift()
| |||||||||||||
| 38 | 6 | ▶ | my $ntab = shift // ''; | ||||||||||
|
Condition100%2/2
shift() // ""
MC/DC100%1/1
shift() // ""
shift()
Truth table100%2/2
A
A= shift()
| |||||||||||||
| 39 | |||||||||||||
| 40 | 6 | $Text::Wrap::columns = $width; | |||||||||||
| 41 | 6 | Text::Wrap::wrap($itab, $ntab, $text); | |||||||||||
| 42 | } | ||||||||||||
| 43 | |||||||||||||
| 44 | 4 | ▶ | sub wrap_filter_factory { | ||||||||||
|
Subroutine
wrap_filter_factory: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||
| 45 | 4 | my ($context, @args) = @_; | |||||||||||
| 46 | 5 | ▶ | return sub { | ||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||
| 47 | 5 | my $text = shift; | |||||||||||
| 48 | 5 | tt_wrap($text, @args); | |||||||||||
| 49 | } | ||||||||||||
| 50 | 4 | } | |||||||||||
| 51 | |||||||||||||
| 52 | |||||||||||||
| 53 | 1 | 1; | |||||||||||
| 54 | |||||||||||||
| 55 | __END__ | ||||||||||||