update docs not to use subrequest
Marcus Ramberg [Sun, 31 Dec 2006 16:43:46 +0000 (16:43 +0000)]
Changes
Email.pm

diff --git a/Changes b/Changes
index 95917b6..2baafe9 100644 (file)
--- a/Changes
+++ b/Changes
@@ -1,5 +1,8 @@
 Revision history for Perl extension Catalyst::Plugin::Email.
 
+0.08
+       - Modernize documentation not to use subrequest.
+
 0.07  2006-12-18 16:08:00
        - Revert change:
           Make it croak if recipient is empty.
index d909b53..c364727 100644 (file)
--- a/Email.pm
+++ b/Email.pm
@@ -116,34 +116,34 @@ sub email {
 =head1 USING WITH A VIEW
 
 A common practice is to handle emails using the same template language used
-for HTML pages.  This can be accomplished by pairing this plugin with
-L<Catalyst::Plugin::SubRequest>.
-
-Here is a short example of rendering an email from a Template Toolkit source
-file.  The call to $c->subreq makes an internal call to the render_email
-method just like an external call from a browser.  The request will pass
-through the end method to be processed by your View class.
+for HTML pages.  If your view supports the 'render' method (Like the TT view 
+does), you just set the body like this:
+  $c->email(
+     header => [
+        To      => 'me@localhost',
+        Subject => 'A TT Email',
+     ],
+     body => $c->view('TT')->render($c,'mytemplate.tt'),
+  }
+
+If your view doesn't support render, you can just forward to it, then reset 
+the body like this:
 
     sub send_email : Local {
         my ( $self, $c ) = @_;  
-
+        {
+        local $c->stash->{names}   = [ qw/andyg sri mst/ ],
+        local $c->stash->{template}= 'mytemplate.tt';   
+        $c->forward($c->view('MyView'));
         $c->email(
             header => [
                 To      => 'me@localhost',
                 Subject => 'A TT Email',
             ],
-            body => $c->subreq( '/render_email' ),
-        );
-        # redirect or display a message
-    }
-    
-    sub render_email : Local {
-        my ( $self, $c ) = @_;
-        
-        $c->stash(
-            names    => [ qw/andyg sri mst/ ],
-            template => 'email.tt',
+            body => $c->res->body,
         );
+        $c->res->body(undef);
+        }
     }
     
 And the template:
@@ -174,12 +174,9 @@ L<Email::MIME::Creator>
 =head1 AUTHOR
 
 Sebastian Riedel, C<sri@cpan.org>
-
-=head1 THANKS
-
-Andy Grundman - Additional documentation
-
-Carl Franks - Additional documentation
+Andy Grundman
+Carl Franks 
+Marcus Ramberg C<mramberg@cpan.org>
 
 =head1 COPYRIGHT