line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Email::MIME::Kit::Renderer::TestRenderer 3.000008; |
2
|
|
|
|
|
|
|
# ABSTRACT: extremely simple renderer for testing purposes only |
3
|
|
|
|
|
|
|
|
4
|
4
|
|
|
4
|
|
71252
|
use v5.20.0; |
|
4
|
|
|
|
|
25
|
|
5
|
4
|
|
|
4
|
|
573
|
use Moose; |
|
4
|
|
|
|
|
471062
|
|
|
4
|
|
|
|
|
25
|
|
6
|
|
|
|
|
|
|
with 'Email::MIME::Kit::Role::Renderer'; |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
#pod =head1 WARNING |
9
|
|
|
|
|
|
|
#pod |
10
|
|
|
|
|
|
|
#pod Seriously, this is horrible code. If you want, look at it. It's swell for |
11
|
|
|
|
|
|
|
#pod testing simple things, but if you use this for real mkits, you're going to be |
12
|
|
|
|
|
|
|
#pod upset by something horrible soon. |
13
|
|
|
|
|
|
|
#pod |
14
|
|
|
|
|
|
|
#pod =head1 DESCRIPTION |
15
|
|
|
|
|
|
|
#pod |
16
|
|
|
|
|
|
|
#pod The test renderer is like a version of Template Toolkit 2 that has had a crayon |
17
|
|
|
|
|
|
|
#pod shoved up its nose and into its brain. It can only do a very few things, but |
18
|
|
|
|
|
|
|
#pod it does them well enough to test simple kits. |
19
|
|
|
|
|
|
|
#pod |
20
|
|
|
|
|
|
|
#pod Given the following template: |
21
|
|
|
|
|
|
|
#pod |
22
|
|
|
|
|
|
|
#pod This will say "I love pie": [% actor %] [% m_obj.verb() %] [% z_by("me") %] |
23
|
|
|
|
|
|
|
#pod |
24
|
|
|
|
|
|
|
#pod ...and the following set of variables: |
25
|
|
|
|
|
|
|
#pod |
26
|
|
|
|
|
|
|
#pod { |
27
|
|
|
|
|
|
|
#pod actor => 'I', |
28
|
|
|
|
|
|
|
#pod m_obj => $object_whose_verb_method_returns_love, |
29
|
|
|
|
|
|
|
#pod z_by => sub { 'me' }, |
30
|
|
|
|
|
|
|
#pod } |
31
|
|
|
|
|
|
|
#pod |
32
|
|
|
|
|
|
|
#pod ..then it will be a true statement. |
33
|
|
|
|
|
|
|
#pod |
34
|
|
|
|
|
|
|
#pod In method calls, the parens are B<not> optional. Anything between them (or |
35
|
|
|
|
|
|
|
#pod between the parens in a coderef call) is evaluated like perl code. For |
36
|
|
|
|
|
|
|
#pod example, this will actually get the OS: |
37
|
|
|
|
|
|
|
#pod |
38
|
|
|
|
|
|
|
#pod [% z_by($^O) %] |
39
|
|
|
|
|
|
|
#pod |
40
|
|
|
|
|
|
|
#pod =cut |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
sub render { |
43
|
25
|
|
|
25
|
0
|
220
|
my ($self, $content_ref, $stash) = @_; |
44
|
|
|
|
|
|
|
|
45
|
25
|
|
|
|
|
49
|
my $output = $$content_ref; |
46
|
25
|
|
|
|
|
199
|
for my $key (sort %$stash) { |
47
|
126
|
|
|
|
|
2351
|
$output =~ |
48
|
|
|
|
|
|
|
s<\[%\s+\Q$key\E(?:(?:\.(\w+))?\((.*?)\))?\s+%\]> |
49
|
|
|
|
|
|
|
[ defined $2 |
50
|
19
|
100
|
|
|
|
623
|
? ($1 ? $stash->{$key}->$1(eval $2) : $stash->{$key}->(eval $2)) |
|
|
100
|
|
|
|
|
|
51
|
|
|
|
|
|
|
: $stash->{$key} |
52
|
|
|
|
|
|
|
]ge; |
53
|
|
|
|
|
|
|
} |
54
|
25
|
|
|
|
|
149
|
|
55
|
|
|
|
|
|
|
return \$output; |
56
|
|
|
|
|
|
|
} |
57
|
4
|
|
|
4
|
|
26415
|
|
|
4
|
|
|
|
|
13
|
|
|
4
|
|
|
|
|
21
|
|
58
|
|
|
|
|
|
|
no Moose; |
59
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
60
|
|
|
|
|
|
|
1; |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
__END__ |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=pod |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=encoding UTF-8 |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=head1 NAME |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
Email::MIME::Kit::Renderer::TestRenderer - extremely simple renderer for testing purposes only |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=head1 VERSION |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
version 3.000008 |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=head1 DESCRIPTION |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
The test renderer is like a version of Template Toolkit 2 that has had a crayon |
79
|
|
|
|
|
|
|
shoved up its nose and into its brain. It can only do a very few things, but |
80
|
|
|
|
|
|
|
it does them well enough to test simple kits. |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
Given the following template: |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
This will say "I love pie": [% actor %] [% m_obj.verb() %] [% z_by("me") %] |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
...and the following set of variables: |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
{ |
89
|
|
|
|
|
|
|
actor => 'I', |
90
|
|
|
|
|
|
|
m_obj => $object_whose_verb_method_returns_love, |
91
|
|
|
|
|
|
|
z_by => sub { 'me' }, |
92
|
|
|
|
|
|
|
} |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
..then it will be a true statement. |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
In method calls, the parens are B<not> optional. Anything between them (or |
97
|
|
|
|
|
|
|
between the parens in a coderef call) is evaluated like perl code. For |
98
|
|
|
|
|
|
|
example, this will actually get the OS: |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
[% z_by($^O) %] |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=head1 PERL VERSION |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
This library should run on perls released even a long time ago. It should |
105
|
|
|
|
|
|
|
work on any version of perl released in the last five years. |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
Although it may work on older versions of perl, no guarantee is made that the |
108
|
|
|
|
|
|
|
minimum required version will not be increased. The version may be increased |
109
|
|
|
|
|
|
|
for any reason, and there is no promise that patches will be accepted to |
110
|
|
|
|
|
|
|
lower the minimum required perl. |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
=head1 WARNING |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
Seriously, this is horrible code. If you want, look at it. It's swell for |
115
|
|
|
|
|
|
|
testing simple things, but if you use this for real mkits, you're going to be |
116
|
|
|
|
|
|
|
upset by something horrible soon. |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
=head1 AUTHOR |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
Ricardo Signes <cpan@semiotic.systems> |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
This software is copyright (c) 2023 by Ricardo Signes. |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
127
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
=cut |