| 1 | package Email::MIME::Kit::Renderer::Text::Template 1.101304; | ||||||||||||||||||||||||||||
| 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 Text::Template | ||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||
| 6 | 1 | ▶ | use Module::Runtime (); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||
| 8 | 8 | ▶ | sub _enref_as_needed { | ||||||||||||||||||||||||||
|
Subroutine
_enref_as_needed: called CC=4 SCAR=14.5
| |||||||||||||||||||||||||||||
| 9 | 8 | my ($self, $hash) = @_; | |||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||
| 11 | 8 | my %return; | |||||||||||||||||||||||||||
| 12 | 8 | ▶ | while (my ($k, $v) = each %$hash) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 13 | 21 | ▶ | $return{ $k } = (ref $v and not blessed $v) ? $v : \$v; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
ref $v and not builtin::blessed($v)
MC/DC0%0/2
ref $v and not builtin::blessed($v)
ref $v
not builtin::blessed($v)
Truth table33%1/3
A and not(B)
A= ref $vB= not builtin::blessed($v)
| |||||||||||||||||||||||||||||
| 14 | } | ||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||
| 16 | 8 | return \%return; | |||||||||||||||||||||||||||
| 17 | } | ||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||
| 19 | #pod =attr template_class | ||||||||||||||||||||||||||||
| 20 | #pod | ||||||||||||||||||||||||||||
| 21 | #pod This attribute stores the name of the class that will be standing in for | ||||||||||||||||||||||||||||
| 22 | #pod Text::Template, if any. It defaults, obviously, to Text::Template. | ||||||||||||||||||||||||||||
| 23 | #pod | ||||||||||||||||||||||||||||
| 24 | #pod =cut | ||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||
| 26 | 1 | has template_class => ( | |||||||||||||||||||||||||||
| 27 | is => 'ro', | ||||||||||||||||||||||||||||
| 28 | isa => 'Str', | ||||||||||||||||||||||||||||
| 29 | default => 'Text::Template', | ||||||||||||||||||||||||||||
| 30 | ); | ||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||
| 32 | #pod =attr template_args | ||||||||||||||||||||||||||||
| 33 | #pod | ||||||||||||||||||||||||||||
| 34 | #pod These are the arguments that will be passed to C<fill_this_in> along with the | ||||||||||||||||||||||||||||
| 35 | #pod template, input, and a few required handlers. | ||||||||||||||||||||||||||||
| 36 | #pod | ||||||||||||||||||||||||||||
| 37 | #pod =cut | ||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||
| 39 | 1 | has template_args => ( | |||||||||||||||||||||||||||
| 40 | is => 'ro', | ||||||||||||||||||||||||||||
| 41 | isa => 'HashRef', | ||||||||||||||||||||||||||||
| 42 | ); | ||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||
| 44 | 8 | ▶ | sub render { | ||||||||||||||||||||||||||
|
Subroutine
render: called CC=4 SCAR=13.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 45 | 8 | my ($self, $input_ref, $args)= @_; | |||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||
| 47 | my $hash = $self->_enref_as_needed({ | ||||||||||||||||||||||||||||
| 48 | 8 | ▶ | (map {; $_ => ref $args->{$_} ? $args->{$_} : \$args->{$_} } keys %$args), | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 49 | }); | ||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||
| 51 | 8 | my $template_class = $self->template_class; | |||||||||||||||||||||||||||
| 52 | 8 | Module::Runtime::require_module($template_class); | |||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||
| 54 | my $result = $template_class->fill_this_in( | ||||||||||||||||||||||||||||
| 55 | $$input_ref, | ||||||||||||||||||||||||||||
| 56 | 8 | ▶ | %{ $self->{template_args} || {} }, | ||||||||||||||||||||||||||
|
Condition50%1/2
$self->{'template_args'} || {}
MC/DC0%0/1
$self->{'template_args'} || {}
$self->{'template_args'}
Truth table50%1/2
A
A= $self->{'template_args'}
| |||||||||||||||||||||||||||||
| 57 | HASH => $hash, | ||||||||||||||||||||||||||||
| 58 | 2 | ▶ | BROKEN => sub { my %hash = @_; die $hash{error}; }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 59 | 8 | ); | |||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||
| 61 | # :-( -- rjbs, 2012-10-01 | ||||||||||||||||||||||||||||
| 62 | 6 | ▶ | die $Text::Template::ERROR unless defined $result; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||
| 64 | 6 | return \$result; | |||||||||||||||||||||||||||
| 65 | } | ||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||
| 67 | 1 | 1; | |||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||
| 69 | __END__ | ||||||||||||||||||||||||||||