[Catalyst-dev] C::V::Email::Template email contents includes wrapper ...

J. Shirley jshirley at gmail.com
Mon Jan 11 15:47:35 GMT 2010


On Mon, Jan 11, 2010 at 7:39 AM, Kiffin Gish <kiffin.gish at planet.nl> wrote:
> I must be doing something really stupid with good old
> C::V::Email::Template, but cannot figure out what. Why oh why isn't it
> working?
>
> I verified everything using the Chapter 11 example of the new Catalyst
> book.
>
> The email arrives alright, but its content has the register.tt2 template
> embedded within the html wrapper.tt2 of my app. Some details:
>
> Controller/Register.pm:
> -----
> $c->stash(
>    email  => {
>        from     => 'no-reply at somewhere.com',
>        to       => "$username <$email>",
>        subject  => 'Registration request',
>        template => 'mail/register.tt2',
>        content_type => 'text/plain',
>    },
> );
>
> $c->forward( $c->view('Email::Template') );
> -----
>
> View/Email/Template.pm
> -----
> package MyApp::View::Email::Template;
>
> use strict;
> use warnings;
>
> use base 'Catalyst::View::Email::Template';
> ---
>
> MyApp.pm:
> -----
> #-- View::Email::Template
> __PACKAGE__->config(
>    'View::Email::Template' => {
>        stash_key => 'email',
>        template_prefix => '',
>        default => {
>            content_type => 'text/plain',
>            charset => 'utf-8',
>        },
>        sender => {
>            mailer => 'SMTP',
>            mailer_args => {
>                Host => 'mail.somewhere.com',
>            },
>       },
>    }
> );
>
> I must be doing something silly, but what?
>
>
> --
> Kiffin Gish <kiffin.gish at planet.nl>
> Gouda, The Netherlands
>


Well, it uses your view template as it is configured.  So, it will use
the wrapper if one exists.  The way I get around this is to wrap the
wrapper.  Something like this:

[%
IF page.wrapper == 'email';
    content;
ELSE;
    # normal wrapper;
END;
%]

You can then just set page.wrapper = 'email' in all of your *email*
templates and it will work.

-J



More information about the Catalyst-dev mailing list