line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
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 |
10
|
|
|
|
|
|
|
# |
11
|
|
|
|
|
|
|
# COPYRIGHT |
12
|
|
|
|
|
|
|
# Copyright (C) 1996-2007 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
|
|
|
1
|
|
3
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
23
|
|
22
|
1
|
|
|
1
|
|
3
|
use warnings; |
|
1
|
|
|
|
|
0
|
|
|
1
|
|
|
|
|
25
|
|
23
|
1
|
|
|
1
|
|
3
|
use base 'Template::Plugin'; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
323
|
|
24
|
1
|
|
|
1
|
|
4
|
use Text::Wrap; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
171
|
|
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
our $VERSION = 2.68; |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub new { |
29
|
3
|
|
|
3
|
1
|
4
|
my ($class, $context, $format) = @_;; |
30
|
3
|
|
|
|
|
9
|
$context->define_filter('wrap', [ \&wrap_filter_factory => 1 ]); |
31
|
3
|
|
|
|
|
8
|
return \&tt_wrap; |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub tt_wrap { |
35
|
6
|
|
|
6
|
0
|
24
|
my $text = shift; |
36
|
6
|
|
100
|
|
|
12
|
my $width = shift || 72; |
37
|
6
|
|
|
|
|
4
|
my $itab = shift; |
38
|
6
|
|
|
|
|
5
|
my $ntab = shift; |
39
|
6
|
100
|
|
|
|
8
|
$itab = '' unless defined $itab; |
40
|
6
|
100
|
|
|
|
7
|
$ntab = '' unless defined $ntab; |
41
|
6
|
|
|
|
|
5
|
$Text::Wrap::columns = $width; |
42
|
6
|
|
|
|
|
16
|
Text::Wrap::wrap($itab, $ntab, $text); |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub wrap_filter_factory { |
46
|
4
|
|
|
4
|
0
|
7
|
my ($context, @args) = @_; |
47
|
|
|
|
|
|
|
return sub { |
48
|
5
|
|
|
5
|
|
13
|
my $text = shift; |
49
|
5
|
|
|
|
|
6
|
tt_wrap($text, @args); |
50
|
|
|
|
|
|
|
} |
51
|
4
|
|
|
|
|
13
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
1; |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
__END__ |