line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Email::MIME::Kit::Renderer::TT; |
2
|
|
|
|
|
|
|
{ |
3
|
|
|
|
|
|
|
$Email::MIME::Kit::Renderer::TT::VERSION = '1.001'; |
4
|
|
|
|
|
|
|
} |
5
|
1
|
|
|
1
|
|
73925
|
use Moose; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
8
|
|
6
|
|
|
|
|
|
|
with 'Email::MIME::Kit::Role::Renderer'; |
7
|
|
|
|
|
|
|
# ABSTRACT: render parts of your mail with Template-Toolkit |
8
|
|
|
|
|
|
|
|
9
|
1
|
|
|
1
|
|
9877
|
use Template 2.1; |
|
1
|
|
|
|
|
28772
|
|
|
1
|
|
|
|
|
262
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
# XXX: _include_path or something |
13
|
|
|
|
|
|
|
# XXX: we can maybe default to the kit dir if the KitReader is Dir |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub render { |
16
|
6
|
|
|
6
|
0
|
74345
|
my ($self, $input_ref, $stash) = @_; |
17
|
6
|
|
50
|
|
|
20
|
$stash ||= {}; |
18
|
|
|
|
|
|
|
|
19
|
6
|
|
|
|
|
10
|
my $output; |
20
|
6
|
50
|
|
|
|
220
|
$self->tt->process($input_ref, $stash, \$output) |
21
|
|
|
|
|
|
|
or die $self->tt->error; |
22
|
|
|
|
|
|
|
|
23
|
6
|
|
|
|
|
42241
|
return \$output; |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
has eval_perl => ( |
27
|
|
|
|
|
|
|
is => 'ro', |
28
|
|
|
|
|
|
|
isa => 'Bool', |
29
|
|
|
|
|
|
|
default => 0, |
30
|
|
|
|
|
|
|
); |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
has strict => ( |
33
|
|
|
|
|
|
|
is => 'ro', |
34
|
|
|
|
|
|
|
isa => 'Bool', |
35
|
|
|
|
|
|
|
default => 1, |
36
|
|
|
|
|
|
|
); |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
has template_parameters => ( |
39
|
|
|
|
|
|
|
is => 'ro', |
40
|
|
|
|
|
|
|
isa => 'HashRef', |
41
|
|
|
|
|
|
|
default => sub { {} }, |
42
|
|
|
|
|
|
|
); |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
has tt => ( |
45
|
|
|
|
|
|
|
is => 'ro', |
46
|
|
|
|
|
|
|
isa => 'Template', |
47
|
|
|
|
|
|
|
lazy => 1, |
48
|
|
|
|
|
|
|
init_arg => undef, |
49
|
|
|
|
|
|
|
default => sub { |
50
|
|
|
|
|
|
|
my ($self) = @_; |
51
|
|
|
|
|
|
|
Template->new({ |
52
|
|
|
|
|
|
|
ABSOLUTE => 0, |
53
|
|
|
|
|
|
|
RELATIVE => 0, |
54
|
|
|
|
|
|
|
STRICT => $self->strict, |
55
|
|
|
|
|
|
|
EVAL_PERL => $self->eval_perl, |
56
|
|
|
|
|
|
|
%{ $self->template_parameters }, |
57
|
|
|
|
|
|
|
}); |
58
|
|
|
|
|
|
|
}, |
59
|
|
|
|
|
|
|
); |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
1; |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
__END__ |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=pod |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=head1 NAME |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
Email::MIME::Kit::Renderer::TT - render parts of your mail with Template-Toolkit |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=head1 VERSION |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
version 1.001 |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=head1 DESCRIPTION |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
This is a renderer plugin for L<Email::MIME::Kit>, and renders message parts |
78
|
|
|
|
|
|
|
using L<Template Toolkit 2|Template>. When specifying a renderer in |
79
|
|
|
|
|
|
|
F<manifest.json>, you might write something like this: |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
{ ..., "renderer": "TT" } |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
Or, to supply options: |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
{ |
86
|
|
|
|
|
|
|
..., |
87
|
|
|
|
|
|
|
"renderer": [ |
88
|
|
|
|
|
|
|
"TT", |
89
|
|
|
|
|
|
|
{ ...params go here... } |
90
|
|
|
|
|
|
|
] |
91
|
|
|
|
|
|
|
} |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
There are only three parameters that can be supplied right now: |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
C<strict> sets the C<STRICT> Template parameter. It defaults to 1. |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
C<eval_perl> sets the C<EVAL_PERL> Template parameter. It defaults to 0. |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
C<template_parameters> can be a hashref of any parameters to be passed to the |
100
|
|
|
|
|
|
|
Template constructor. Setting C<STRICT> or C<EVAL_PERL> here overrides the |
101
|
|
|
|
|
|
|
C<strict> and C<eval_perl> options. |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
=head1 AUTHOR |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
Ricardo SIGNES <rjbs@cpan.org> |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
This software is copyright (c) 2013 by Ricardo SIGNES. |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
112
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
=cut |