| 1 | package Email::MIME::Kit::Renderer::TT 1.003; | ||||||||||||
| 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 | 6 | ▶ | sub render { | ||||||||||
|
Subroutine
render: called CC=3 SCAR=11.3
Pod
undocumented
| |||||||||||||
| 42 | 6 | my ($self, $input_ref, $stash) = @_; | |||||||||||
| 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 | 1 | ▶ | default => sub { | ||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||
| 76 | 1 | my ($self) = @_; | |||||||||||
| 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__ | ||||||||||||