| 1 | package Email::MIME::Kit::Renderer::MicroMason; | ||||||||||||
| 2 | |||||||||||||
| 3 | # ABSTRACT: Render parts of your mail with Text::MicroMason | ||||||||||||
| 4 | |||||||||||||
| 5 | 3 | ▶ | use Moose; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 6 | 3 | with 'Email::MIME::Kit::Role::Renderer'; | |||||||||||
| 7 | 3 | ▶ | use Scalar::Util (); | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 8 | 3 | ▶ | use Text::MicroMason; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 9 | 3 | ▶ | use Carp; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 10 | |||||||||||||
| 11 | 3 | our $VERSION = '1.21'; | |||||||||||
| 12 | |||||||||||||
| 13 | 8 | ▶ | sub render { | ||||||||||
|
Subroutine
render: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||
| 14 | 8 | my ( $self, $content_ref, $stash ) = @_; | |||||||||||
| 15 | 8 | ▶ | $stash ||= {}; | ||||||||||
|
Condition50%1/2
$stash ||= {}
MC/DC0%0/1
$stash ||= {}
$stash
Truth table50%1/2
A
A= $stash
| |||||||||||||
| 16 | |||||||||||||
| 17 | # Parse the template with Text::MicroMason | ||||||||||||
| 18 | 8 | my $outbuf = $self->mason->execute( text => $$content_ref, %$stash ); | |||||||||||
| 19 | |||||||||||||
| 20 | 8 | return \$outbuf; | |||||||||||
| 21 | } | ||||||||||||
| 22 | |||||||||||||
| 23 | has mason => ( | ||||||||||||
| 24 | is => 'ro', | ||||||||||||
| 25 | ## isa => 'Text::MicroMason', # T:MM isa strange subclass | ||||||||||||
| 26 | lazy => 1, | ||||||||||||
| 27 | init_arg => undef, | ||||||||||||
| 28 | 2 | ▶ | default => sub { | ||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||
| 29 | 2 | my ($self) = @_; | |||||||||||
| 30 | 2 | my $mason = Text::MicroMason->new('-Filters', '-MKit'); | |||||||||||
| 31 | 2 | $mason->{__mkit_renderer} = $self; | |||||||||||
| 32 | 2 | Scalar::Util::weaken($mason->{__mkit_renderer}); | |||||||||||
| 33 | 2 | return $mason; | |||||||||||
| 34 | }, | ||||||||||||
| 35 | 3 | ); | |||||||||||
| 36 | |||||||||||||
| 37 | { | ||||||||||||
| 38 | 3 | $INC{'Text/MicroMason/MKit.pm'} = 1; | |||||||||||
| 39 | package Text::MicroMason::MKit; | ||||||||||||
| 40 | |||||||||||||
| 41 | 2 | ▶ | sub read_file { | ||||||||||
|
Subroutine
read_file: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||
| 42 | 2 | my ($self, $file) = @_; | |||||||||||
| 43 | 2 | my $text = $self->{__mkit_renderer}->kit->get_kit_entry($file); | |||||||||||
| 44 | 2 | return $$text; | |||||||||||
| 45 | } | ||||||||||||
| 46 | } | ||||||||||||
| 47 | |||||||||||||
| 48 | 3 | ▶ | no Moose; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 49 | 3 | 1; | |||||||||||
| 50 | |||||||||||||
| 51 | __END__ | ||||||||||||