Skip to content

Commit

Permalink
add encoding option
Browse files Browse the repository at this point in the history
  • Loading branch information
Arthur Axel 'fREW' Schmidt committed May 20, 2014
1 parent 5d63f1c commit 3975100
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions lib/Email/MIME/Kit/Renderer/Xslate.pm
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,22 @@ with 'Email::MIME::Kit::Role::Renderer';
# ABSTRACT: render parts of your mail with Text::Xslate

use Text::Xslate;
use Encode;

sub render {
my ($self, $tpl, $stash) = @_;

\($self->_render_tx($$tpl, $stash||{}))
my $text = $self->_render_tx($$tpl, $stash||{});
$text = encode($self->encoding, $text) if $self->encoding;

\$text;
}

has encoding => (
is => 'ro',
default => 'UTF-8',
);

has options => (
is => 'ro',
default => sub { {} },
Expand Down Expand Up @@ -51,12 +60,16 @@ Or, to supply options:
"options": {
"syntax": "Kolon"
// etc etc
}
},
"encoding": "UTF-16"
}
]
}
All options are passed verbatim to C<< Text::Xslate->new >>.
C<options> are passed verbatim to C<< Text::Xslate->new >>.
C<encoding> will handle convertion the generated template from characters to
bytes. The default is C<UTF-8>.
For plaintext emails a good default is
Expand Down

0 comments on commit 3975100

Please sign in to comment.