Catalyst::View::Email::Templateが空気を読まない件

Catalyst::Plugin::EmailからCatalyst::View::Email::Templateに乗り換えようとした。
どうでもいいが、中の人はCatalyst::Plugin排斥より、デフォルトで$cに依存しないでモデル呼べるようにするのが先じゃねーのと思う。


んでこのCatalyst::View::Email::Templateの何がkyかというと、文字コードの指定が出来ない。
とりあえず親クラスのCatalyst::View::Emailを見る。

% perldoc Catalyst::View::Email

CONFIGURATION

__PACKAGE__->config(
    ’View::Email’ => {
        stash_key => ’email’,
        default => {
            content_type => ’text/plain’,
            charset => ’utf-8’

charsetが指定できるようだ。
試す。
文字化ける。
ソース読む。

Catalyst::View::Email::Template

sub generate_part {
    my ($self, $c, $attrs) = @_;

    my $template_prefix         = $self->{template_prefix};
    my $default_view            = $self->{default}->{view};
    my $default_content_type    = $self->{default}->{content_type};
    my $default_charset         = $self->{default}->{charset};

    my $view;
    # use the view specified for the email part
    if (exists $attrs->{view} && defined $attrs->{view} && $attrs->{view} ne '') {
        $view = $c->view($attrs->{view});
        $c->log->debug("C::V::Email::Template uses specified view $view for rendering.") if $c->debug;
    }
    # if none specified use the configured default view
    elsif ($default_view) {
        $view = $c->view($default_view);
        $c->log->debug("C::V::Email::Template uses default view $view for rendering.") if $c->debug;;
    }
    # else fallback to Catalysts default view
    else {
        $view = $c->view;
        $c->log->debug("C::V::Email::Template uses Catalysts default view $view for rendering.") if $c->debug;;
    }

    # validate the per template view
    $self->_validate_view($view);

    # prefix with template_prefix if configured
    my $template = $template_prefix ne '' ? join('/', $template_prefix, $attrs->{template}) : $attrs->{template};

    # setup the attributes (merge with defaults)
    my $e_m_attrs = $self->setup_attributes($c, $attrs);

    # render the email part
    my $output = $view->render( $c, $template, {
        content_type    => $e_m_attrs->{content_type},
        stash_key       => $self->{stash_key},
        %{$c->stash},
    });

    if ( ref $output ) {
        croak $output->can('as_string') ? $output->as_string : $output;
    }

    return Email::MIME->create(
        attributes => $e_m_attrs,
        body       => $output,
    );
}


ええと。

my $default_charset         = $self->{default}->{charset};

で取得した文字コードを使ってない。fuck


ググるhttp://journal.soffritto.org/entry/319が引っかかる。
やっぱこういうことするしかないよね。
もしくはCatalyst::View::Emailを使うようにして、自分でencodeしたbodyを渡してやるか。