[Catalyst-dev] C::V::Email::Template email contents includes
wrapper ...
Kiffin Gish
kiffin.gish at planet.nl
Mon Jan 11 16:11:40 GMT 2010
Thanks guy, it works like a charm!
I'm a bit surprised that it's not mentioned in any of the documentation,
or is it?
On Mon, 2010-01-11 at 07:47 -0800, J. Shirley wrote:
> 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
>
> _______________________________________________
> Catalyst-dev mailing list
> Catalyst-dev at lists.scsys.co.uk
> http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst-dev
--
Kiffin Gish <kiffin.gish at planet.nl>
Gouda, The Netherlands
More information about the Catalyst-dev
mailing list