line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Mail::Builder::Simple::HTML::Template; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
781
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
37
|
|
4
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
34
|
|
5
|
1
|
|
|
1
|
|
2379
|
use HTML::Template; |
|
1
|
|
|
|
|
15821
|
|
|
1
|
|
|
|
|
37
|
|
6
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
30
|
use 5.008_008; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
245
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our $VERSION = '0.03'; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub new { |
12
|
2
|
|
|
2
|
1
|
1490
|
my ( $class, $args, $vars ) = @_; |
13
|
|
|
|
|
|
|
|
14
|
2
|
|
|
|
|
5
|
my $self = { |
15
|
|
|
|
|
|
|
template_args => $args, |
16
|
|
|
|
|
|
|
template_vars => $vars, |
17
|
|
|
|
|
|
|
}; |
18
|
|
|
|
|
|
|
|
19
|
2
|
|
|
|
|
7
|
return bless $self, $class; |
20
|
|
|
|
|
|
|
} |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub process { |
23
|
1
|
|
|
1
|
1
|
877
|
my ( $self, $template, $source ) = @_; |
24
|
|
|
|
|
|
|
|
25
|
1
|
|
|
|
|
6
|
my $args = $self->{template_args}; |
26
|
1
|
|
50
|
|
|
10
|
$args->{path} ||= q{.}; |
27
|
1
|
|
50
|
|
|
7
|
$args->{ENCODING} ||= 'utf8'; |
28
|
1
|
50
|
33
|
|
|
9
|
$args->{die_on_bad_params} = ($args->{die_on_bad_params} |
29
|
|
|
|
|
|
|
and $args->{die_on_bad_params} eq 'yes') ? 1 : 0; |
30
|
|
|
|
|
|
|
|
31
|
1
|
|
|
|
|
2
|
my $t; |
32
|
1
|
50
|
|
|
|
4
|
if ( $source eq 'file' ) { |
|
|
50
|
|
|
|
|
|
33
|
0
|
|
|
|
|
0
|
$t = HTML::Template->new( filename => $template, %{$args} ); |
|
0
|
|
|
|
|
0
|
|
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
elsif ( $source eq 'scalar' ) { |
36
|
1
|
|
|
|
|
2
|
$t = HTML::Template->new( scalarref => \$template, %{$args} ); |
|
1
|
|
|
|
|
6
|
|
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
1
|
|
|
|
|
1333
|
$t->param( %{ $self->{template_vars} } ); |
|
1
|
|
|
|
|
8
|
|
40
|
|
|
|
|
|
|
|
41
|
1
|
|
|
|
|
44
|
return $t->output; |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
1; |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
__END__ |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
=head1 NAME |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
Mail::Builder::Simple::HTML::Template - H::T plugin for Mail::Builder::Simple |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=head1 VERSION |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
Version 0.03 |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=head1 SYNOPSIS |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
my $template = Mail::Builder::Simple::HTML::Template->new($args, $vars); |
59
|
|
|
|
|
|
|
$template->process($template, $source); |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
=head1 DESCRIPTION |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
This module shouldn't be used directly, but as a plugin of L<Mail::Builder::Simple|Mail::Builder::Simple> for sending email messages with the body or the attachments created using L<HTML::Template|HTML::Template>. |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=head1 SUBROUTINES/METHODS |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=head2 new |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
C<new()> is the class constructor. It accepts 2 parameters: $args and $vars. |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
$args is a hashref with the options for TT. $vars is the hashref with the template variables. |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=head2 process |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
C<process()> processes the template. It accepts 2 parameters: $template and $source. |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
$source can be either "file" or "scalar". If $source eq "file", $template is the name of the template file. If $source eq "scalar", $template is the scalar variable that contains the template. |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
=head1 DIAGNOSTICS |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=head1 CONFIGURATION AND ENVIRONMENT |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
This module doesn't require any configuration. |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=head1 DEPENDENCIES |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
L<HTML::Template|HTML::Template> |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=head1 INCOMPATIBILITIES |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
Not known incompatibilities. |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
=head1 BUGS AND LIMITATIONS |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
Not known bugs. If you find some, please announce. |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=head1 SEE ALSO |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
L<Mail::Builder::Simple|Mail::Builder::Simple>, L<HTML::Template|HTML::Template> |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
=head1 AUTHOR |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
Octavian Rasnita <orasnita@gmail.com> |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
=head1 LICENSE AND COPYRIGHT |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it under |
108
|
|
|
|
|
|
|
the same terms as Perl itself. |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
=cut |