line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
use Moose; |
2
|
1
|
|
|
1
|
|
66159
|
with 'Email::MIME::Kit::Role::Renderer'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
6
|
|
3
|
|
|
|
|
|
|
# ABSTRACT: render parts of your mail with Template-Toolkit |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
use Template 2.1; |
6
|
1
|
|
|
1
|
|
6063
|
|
|
1
|
|
|
|
|
16156
|
|
|
1
|
|
|
|
|
190
|
|
7
|
|
|
|
|
|
|
#pod =head1 DESCRIPTION |
8
|
|
|
|
|
|
|
#pod |
9
|
|
|
|
|
|
|
#pod This is a renderer plugin for L<Email::MIME::Kit>, and renders message parts |
10
|
|
|
|
|
|
|
#pod using L<Template Toolkit 2|Template>. When specifying a renderer in |
11
|
|
|
|
|
|
|
#pod F<manifest.json>, you might write something like this: |
12
|
|
|
|
|
|
|
#pod |
13
|
|
|
|
|
|
|
#pod { ..., "renderer": "TT" } |
14
|
|
|
|
|
|
|
#pod |
15
|
|
|
|
|
|
|
#pod Or, to supply options: |
16
|
|
|
|
|
|
|
#pod |
17
|
|
|
|
|
|
|
#pod { |
18
|
|
|
|
|
|
|
#pod ..., |
19
|
|
|
|
|
|
|
#pod "renderer": [ |
20
|
|
|
|
|
|
|
#pod "TT", |
21
|
|
|
|
|
|
|
#pod { ...params go here... } |
22
|
|
|
|
|
|
|
#pod ] |
23
|
|
|
|
|
|
|
#pod } |
24
|
|
|
|
|
|
|
#pod |
25
|
|
|
|
|
|
|
#pod There are only three parameters that can be supplied right now: |
26
|
|
|
|
|
|
|
#pod |
27
|
|
|
|
|
|
|
#pod C<strict> sets the C<STRICT> Template parameter. It defaults to 1. |
28
|
|
|
|
|
|
|
#pod |
29
|
|
|
|
|
|
|
#pod C<eval_perl> sets the C<EVAL_PERL> Template parameter. It defaults to 0. |
30
|
|
|
|
|
|
|
#pod |
31
|
|
|
|
|
|
|
#pod C<template_parameters> can be a hashref of any parameters to be passed to the |
32
|
|
|
|
|
|
|
#pod Template constructor. Setting C<STRICT> or C<EVAL_PERL> here overrides the |
33
|
|
|
|
|
|
|
#pod C<strict> and C<eval_perl> options. |
34
|
|
|
|
|
|
|
#pod |
35
|
|
|
|
|
|
|
#pod =cut |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
# XXX: _include_path or something |
38
|
|
|
|
|
|
|
# XXX: we can maybe default to the kit dir if the KitReader is Dir |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
my ($self, $input_ref, $stash) = @_; |
41
|
|
|
|
|
|
|
$stash ||= {}; |
42
|
6
|
|
|
6
|
0
|
88922
|
|
43
|
6
|
|
50
|
|
|
22
|
my $output; |
44
|
|
|
|
|
|
|
$self->_tt->process($input_ref, $stash, \$output) |
45
|
6
|
|
|
|
|
10
|
or die $self->_tt->error; |
46
|
6
|
50
|
|
|
|
186
|
|
47
|
|
|
|
|
|
|
return \$output; |
48
|
|
|
|
|
|
|
} |
49
|
6
|
|
|
|
|
35163
|
|
50
|
|
|
|
|
|
|
has eval_perl => ( |
51
|
|
|
|
|
|
|
is => 'ro', |
52
|
|
|
|
|
|
|
isa => 'Bool', |
53
|
|
|
|
|
|
|
default => 0, |
54
|
|
|
|
|
|
|
); |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
has strict => ( |
57
|
|
|
|
|
|
|
is => 'ro', |
58
|
|
|
|
|
|
|
isa => 'Bool', |
59
|
|
|
|
|
|
|
default => 1, |
60
|
|
|
|
|
|
|
); |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
has template_parameters => ( |
63
|
|
|
|
|
|
|
is => 'ro', |
64
|
|
|
|
|
|
|
isa => 'HashRef', |
65
|
|
|
|
|
|
|
default => sub { {} }, |
66
|
|
|
|
|
|
|
); |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
has _tt => ( |
69
|
|
|
|
|
|
|
is => 'ro', |
70
|
|
|
|
|
|
|
isa => 'Template', |
71
|
|
|
|
|
|
|
lazy => 1, |
72
|
|
|
|
|
|
|
init_arg => undef, |
73
|
|
|
|
|
|
|
default => sub { |
74
|
|
|
|
|
|
|
my ($self) = @_; |
75
|
|
|
|
|
|
|
Template->new({ |
76
|
|
|
|
|
|
|
ABSOLUTE => 0, |
77
|
|
|
|
|
|
|
RELATIVE => 0, |
78
|
|
|
|
|
|
|
STRICT => $self->strict, |
79
|
|
|
|
|
|
|
EVAL_PERL => $self->eval_perl, |
80
|
|
|
|
|
|
|
%{ $self->template_parameters }, |
81
|
|
|
|
|
|
|
}); |
82
|
|
|
|
|
|
|
}, |
83
|
|
|
|
|
|
|
); |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
1; |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=pod |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=encoding UTF-8 |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
=head1 NAME |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
Email::MIME::Kit::Renderer::TT - render parts of your mail with Template-Toolkit |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=head1 VERSION |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
version 1.002 |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
=head1 DESCRIPTION |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
This is a renderer plugin for L<Email::MIME::Kit>, and renders message parts |
103
|
|
|
|
|
|
|
using L<Template Toolkit 2|Template>. When specifying a renderer in |
104
|
|
|
|
|
|
|
F<manifest.json>, you might write something like this: |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
{ ..., "renderer": "TT" } |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
Or, to supply options: |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
{ |
111
|
|
|
|
|
|
|
..., |
112
|
|
|
|
|
|
|
"renderer": [ |
113
|
|
|
|
|
|
|
"TT", |
114
|
|
|
|
|
|
|
{ ...params go here... } |
115
|
|
|
|
|
|
|
] |
116
|
|
|
|
|
|
|
} |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
There are only three parameters that can be supplied right now: |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
C<strict> sets the C<STRICT> Template parameter. It defaults to 1. |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
C<eval_perl> sets the C<EVAL_PERL> Template parameter. It defaults to 0. |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
C<template_parameters> can be a hashref of any parameters to be passed to the |
125
|
|
|
|
|
|
|
Template constructor. Setting C<STRICT> or C<EVAL_PERL> here overrides the |
126
|
|
|
|
|
|
|
C<strict> and C<eval_perl> options. |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
=head1 PERL VERSION |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
This module should work on any version of perl still receiving updates from |
131
|
|
|
|
|
|
|
the Perl 5 Porters. This means it should work on any version of perl released |
132
|
|
|
|
|
|
|
in the last two to three years. (That is, if the most recently released |
133
|
|
|
|
|
|
|
version is v5.40, then this module should work on both v5.40 and v5.38.) |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
Although it may work on older versions of perl, no guarantee is made that the |
136
|
|
|
|
|
|
|
minimum required version will not be increased. The version may be increased |
137
|
|
|
|
|
|
|
for any reason, and there is no promise that patches will be accepted to lower |
138
|
|
|
|
|
|
|
the minimum required perl. |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
=head1 AUTHOR |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
Ricardo SIGNES <rjbs@semiotic.systems> |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
This software is copyright (c) 2022 by Ricardo SIGNES. |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
149
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
=cut |