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