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