blib/lib/Template/Plugin/Clickable/Email.pm

filter: Statementstmt 100% 24 / 24 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 7 / 7 Podpod 0.0% 0 / 1 totaltotal 96.8% 31 / 32 CC 1 SCAR 0.0
CC
1
Cov
100%
BEGIN
1.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.0
↑ Summary
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 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
28 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
29  
30 2 ▶use Template::Plugin::Filter;
Subroutine BEGIN: called CC=1 SCAR=0.0
31 2 ▶use base qw(Template::Plugin::Filter);
Subroutine BEGIN: called CC=1 SCAR=0.0
32  
33 2 ▶use Email::Find;
Subroutine BEGIN: called CC=1 SCAR=0.0
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 2 our $VERSION = '0.01';
46  
47 2 ▶sub filter {
Subroutine filter: called CC=1 SCAR=0.0
Pod undocumented
48 2 my($self, $text) = @_;
49 my $finder =
50 Email::Find->new(
51 2 ▶ sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
52 2 my($email, $orig_email) = @_;
53 2 my($address) = $email->format;
54 2 return qq|<a href="mailto:$address">$orig_email</a>|;
55 },
56 2 );
57 2 $finder->find(\$text);
58 2 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 <p>Some text that contains an address: nik@FreeBSD.org.</p>
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<mailto:> 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<< <nik@FreeBSD.org> >>
87  
88 =head1 BUGS
89  
90 Please report any bugs or feature requests to
91 C<bug-template-plugin-clickable-email@rt.cpan.org>, or through the web interface at
92 L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Template-Plugin-Clickable-Email>.
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 2 1; # End of Template::Plugin::Clickable::Email
↑ Summary