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