File Coverage

blib/lib/Template/Plugin/Clickable/Email.pm
Criterion Covered Total %
statement 22 22 100.0
branch n/a
condition n/a
subroutine 7 7 100.0
pod 0 1 0.0
total 29 30 96.6


line stmt bran cond sub pod time code
1             package Template::Plugin::Clickable::Email;
2              
3             # Copyright (c) 2005 Nik Clayton
4             # All rights reserved.
5             #
6             # Redistribution and use in source and binary forms, with or without
7             # modification, are permitted provided that the following conditions
8             # are met:
9             # 1. Redistributions of source code must retain the above copyright
10             # notice, this list of conditions and the following disclaimer.
11             # 2. Redistributions in binary form must reproduce the above copyright
12             # notice, this list of conditions and the following disclaimer in the
13             # documentation and/or other materials provided with the distribution.
14             #
15             # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16             # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17             # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18             # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19             # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20             # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21             # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22             # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23             # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24             # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25             # SUCH DAMAGE.
26              
27 2     2   84196 use warnings;
  2         4  
  2         65  
28 2     2   8 use strict;
  2         3  
  2         60  
29              
30 2     2   1539 use Template::Plugin::Filter;
  2         8555  
  2         58  
31 2     2   13 use base qw(Template::Plugin::Filter);
  2         2  
  2         155  
32              
33 2     2   1494 use Email::Find;
  2         262733  
  2         481  
34              
35             =head1 NAME
36              
37             Template::Plugin::Clickable::Email - Make email addresses in to HTML links
38              
39             =head1 VERSION
40              
41             Version 0.01
42              
43             =cut
44              
45             our $VERSION = '0.01';
46              
47             sub filter {
48 2     2 0 3779 my($self, $text) = @_;
49             my $finder =
50             Email::Find->new(
51             sub {
52 2     2   3063 my($email, $orig_email) = @_;
53 2         9 my($address) = $email->format;
54 2         45 return qq|$orig_email|;
55             },
56 2         17 );
57 2         22 $finder->find(\$text);
58 2         41 return $text;
59             }
60              
61             =head1 SYNOPSIS
62              
63             [% USE link_emails = Clickable::Email %]
64              
65             Then
66              
67             [% text | $link_emails %]
68              
69             or
70              
71             [% FILTER $link_emails %]
72            

Some text that contains an address: nik@FreeBSD.org.

73             [% END %]
74              
75             =head1 DESCRIPTION
76              
77             Template::Plugin::Clickable::Email converts any e-mail addresses found in
78             the filtered text in to HTML C links.
79              
80             This module uses Email::Find, see the documentation for that module for
81             caveats relating to how addresses are parsed, and why some false positives
82             may occur.
83              
84             =head1 AUTHOR
85              
86             Nik Clayton, C<< >>
87              
88             =head1 BUGS
89              
90             Please report any bugs or feature requests to
91             C, or through the web interface at
92             L.
93             I will be notified, and then you'll automatically be notified of progress on
94             your bug as I make changes.
95              
96             =head1 COPYRIGHT & LICENSE
97              
98             Copyright (c) 2005 Nik Clayton
99             All rights reserved.
100              
101             Redistribution and use in source and binary forms, with or without
102             modification, are permitted provided that the following conditions
103             are met:
104              
105             1. Redistributions of source code must retain the above copyright
106             notice, this list of conditions and the following disclaimer.
107             2. Redistributions in binary form must reproduce the above copyright
108             notice, this list of conditions and the following disclaimer in the
109             documentation and/or other materials provided with the distribution.
110              
111             THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
112             ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
113             IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
114             ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
115             FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
116             DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
117             OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
118             HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
119             LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
120             OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
121             SUCH DAMAGE.
122              
123             =cut
124              
125             1; # End of Template::Plugin::Clickable::Email