Scenario

You're trying to send an email (via Catalyst::Plugin::Email, MIME::Lite, Email::Sender::Simple, your choice) and you would like to be able to stuff your canned email messages into their respective Template::Toolkit templates. One way to do this is use Catalyst::View::Email::Template, which is pretty cool, but forces you to use Catalyst::View::Email, which some people aren't too keen one. So, you can do something like this:

sub email_stuff : Local {
    my ($self, $c, $review_id) = @_;

    $c->stash(
        review_url   => $c->uri_for("/thingy/${review_id}"),
        status_msg =>"Thanks for your feedback!"
        template     => 'view_all.tt2',
    );

    $c->email(
        header => [
            From    => $c->config->{'from'},
            To      => $c->config->{'to'},
            Subject => "Emaily stuff!",
        ],
        body => $c->view('TT')->render($c, 'review.tt2'),
    );

    return; 
}

The line $c->view('TT')->render($c, 'review.tt2'), allows you to have your view render your template for you using all the things you put into $c->stash. Pretty cool eh?

My tags:
 
Popular tags:
 
Powered by Catalyst
Powered by MojoMojo Hosted by Shadowcat - Managed by Nordaaker