-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Arthur Axel 'fREW' Schmidt
committed
May 20, 2014
0 parents
commit 5d63f1c
Showing
8 changed files
with
164 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
.build | ||
Email-MIME-Kit-Renderer-Xslate-* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
language: perl | ||
perl: | ||
- "5.18" | ||
- "5.16" | ||
- "5.14" | ||
- "5.12" | ||
- "5.10" | ||
- "5.8" | ||
|
||
install: | ||
- export RELEASE_TESTING=1 AUTOMATED_TESTING=1 AUTHOR_TESTING=1 HARNESS_OPTIONS=j10:c HARNESS_TIMER=1 | ||
- cpanm --quiet --notest Devel::Cover::Report::Coveralls | ||
- cpanm --quiet --notest --installdeps . | ||
|
||
script: | ||
- PERL5OPT=-MDevel::Cover=-coverage,statement,branch,condition,path,subroutine prove -lrsv t | ||
- cover | ||
|
||
after_success: | ||
- cover -report coveralls |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
Revision history for {{$dist->name}} | ||
|
||
{{$NEXT}} | ||
- Initial Release |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
requires 'Email::MIME::Kit' => 2; | ||
requires 'Text::Xslate' => '3.2.4'; | ||
|
||
on test => sub { | ||
requires 'Test::More' => 0.94; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
name = Email-MIME-Kit-Renderer-Xslate | ||
author = Arthur Axel "fREW" Schmidt <frioux+cpan@gmail.com> | ||
license = Perl_5 | ||
copyright_holder = Arthur Axel "fREW" Schmidt | ||
version = 0.001000 | ||
|
||
[NextRelease] | ||
[@Git] | ||
[@Basic] | ||
[GithubMeta] | ||
issues = 1 | ||
|
||
[MetaJSON] | ||
[PodWeaver] | ||
[PkgVersion] | ||
[ReadmeFromPod] | ||
[PodSyntaxTests] | ||
[Prereqs::FromCPANfile] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
package Email::MIME::Kit::Renderer::Xslate; | ||
|
||
use Moose; | ||
with 'Email::MIME::Kit::Role::Renderer'; | ||
|
||
# ABSTRACT: render parts of your mail with Text::Xslate | ||
|
||
use Text::Xslate; | ||
|
||
sub render { | ||
my ($self, $tpl, $stash) = @_; | ||
|
||
\($self->_render_tx($$tpl, $stash||{})) | ||
} | ||
|
||
has options => ( | ||
is => 'ro', | ||
default => sub { {} }, | ||
); | ||
|
||
has _tx => ( | ||
is => 'ro', | ||
lazy => 1, | ||
init_arg => undef, | ||
default => sub { Text::Xslate->new(shift->options) }, | ||
handles => { | ||
_render_tx => 'render_string', | ||
}, | ||
); | ||
|
||
1; | ||
|
||
__END__ | ||
=pod | ||
=head1 DESCRIPTION | ||
This is a renderer plugin for L<Email::MIME::Kit>, and renders message parts | ||
using L<Text::Xslate>. When specifying a renderer in F<manifest.json>, you | ||
might write something like this: | ||
{ ..., "renderer": "Xslate" } | ||
Or, to supply options: | ||
{ | ||
..., | ||
"renderer": [ | ||
"Xslate", { | ||
"options": { | ||
"syntax": "Kolon" | ||
// etc etc | ||
} | ||
} | ||
] | ||
} | ||
All options are passed verbatim to C<< Text::Xslate->new >>. | ||
For plaintext emails a good default is | ||
"renderer": [ | ||
"Xslate", { | ||
"options": { "type":"text" } | ||
} | ||
] | ||
=cut |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#!/usr/bin/env perl | ||
|
||
use strict; | ||
use warnings; | ||
|
||
use Test::More; | ||
|
||
use Email::MIME::Kit; | ||
|
||
my $kit = Email::MIME::Kit->new({ | ||
source => 't/kits/test.mkit', | ||
}); | ||
|
||
my $email_1 = $kit->assemble({ | ||
name => 'Reticulo Johnson', | ||
game => "eatin' pancakes", | ||
}); | ||
|
||
like( | ||
$email_1->body, | ||
qr{\QReticulo Johnson is my name, eatin' pancakes is my game}, | ||
"tt stuff happened", | ||
); | ||
|
||
my $email_2 = $kit->assemble({ | ||
name => 'Bryan Allen', | ||
game => "nukin' jar cheese", | ||
}); | ||
|
||
like( | ||
$email_2->body, | ||
qr{\QBryan Allen is my name, nukin' jar cheese is my game}, | ||
"tt stuff happened", | ||
); | ||
|
||
done_testing; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"renderer": ["Xslate", { "options": { "type":"text" } }], | ||
"header": [ | ||
{ "Subject": "Test TT Message" }, | ||
{ "From": "test@example.com" } | ||
], | ||
"type": "text/plain", | ||
"body": "<: $name :> is my name, <: $game :> is my game." | ||
} |