line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Template::Plugin::Text::Widont; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
2085138
|
use strict; |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
79
|
|
4
|
2
|
|
|
2
|
|
11
|
use warnings; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
162
|
|
5
|
|
|
|
|
|
|
|
6
|
2
|
|
|
2
|
|
23
|
use base qw/ Template::Plugin::Filter /; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
2206
|
|
7
|
|
|
|
|
|
|
|
8
|
2
|
|
|
2
|
|
100156
|
use Text::Widont (); |
|
2
|
|
|
|
|
1678
|
|
|
2
|
|
|
|
|
374
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
our $VERSION = '0.01'; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
=head1 NAME |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
Template::Plugin::Text::Widont - A Template Toolkit filter for removing typographic widows |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
=head1 SYNOPSIS |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
[% USE Text::Widont nbsp => 'html' %] |
20
|
|
|
|
|
|
|
[% "If the world didn't suck, we'd all fall off" | widont %] |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
=head1 DESCRIPTION |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
C provides a simple |
26
|
|
|
|
|
|
|
L filter interface to the L module.
27
28
See the L
29
section in L's documentation for more information about
30
available values for C.
31
32
33
=head1 METHODS
34
35
=head2 init
36
37
Overrides the method from L.
38
39
40
=cut
41
42
43
sub init {
44
1
1
1
98
my $self = shift;
45
46
# Determine the name to use for the filter - see Template::Plugin::Filter
47
# for details...
48
1
50
19
my $name = $self->{_CONFIG}->{name} # name from the template config
49
|| $self->{_ARGS}->[0] # from the template argument
50
|| 'widont'; # or use widont by default
51
52
1
7
$self->install_filter($name);
53
1
42
return $self;
54
}
55
56
57
=head2 filter
58
59
Overrides the method from L.
60
61
62
=cut
63
64
65
sub filter {
66
1
1
1
66
my ( $self, $text, $args, $config ) = @_;
67
68
1
8
$config = $self->merge_config($config);
69
70
# If we haven't already created a Text::Widont object, do so...
71
1
33
17
$self->{tw} ||= Text::Widont->new( nbsp => $config->{nbsp} );
72
73
# Return the transformed string...
74
1
16
return $self->{tw}->widont($text);
75
}
76
77
78
79
1; # End of the module code; everything from here is documentation...
80
__END__
|