.--- On Mon, 13 Mar 2006, Ryan Perry wrote:
| Interesting solution. Any reason not to just:
|
| my $body=$m->scomp('/pagetosend.html', someArgs => \%hash);
`---
A few come to mind, but they are by no means hard and fast. Since I
wasn't familiar with your specifics, I had to play it extra-safe.
(1) You'd wind up with location of your page hard-coded. To avoid
this, you could always $m->scomp($m->base_comp) or
$m->scomp($m->request_comp), depending on which you mean.
(2) Code in your document would be run twice, since your goal was to
have the page run normally, and ALSO have the page mailed. That
might be bad, or maybe not. At the very least it would nearly
double the work the server has to do to get a page out. I suppose
you could hand in an arg that says: don't actually run the code
again. But then the content might be different, and you'd have to
get around that, and it would all get ugly. Maybe there's a good
way to do this that I just haven't thought of.
(3) I tried to make it self-contained for neatness.
If you don't have any code in the document or component, or if it's
safe to run twice, you're home free -- you can just scomp() it and
send yourself a copy.
If your case is simple, you could just scomp a subcomponent in your
init block:
<%init>
my $page = $m->scomp('.the_page');
mail_it_to_me($page);
</%init>
<% $page %>
<%def .the_page>
Bunch of stuff.
</%def>
That's pretty sweet, but it suffers from the weakness that it only
mails the output of that component. To apply this the way we did
before to include the whole wrapping chain, you might, in your top
level or master handler:
% my $content = $m->scomp($m->fetch_next);
% email_it($content)
<% $content %>
But of course, that won't capture the outermost wrapping layer, so if
your master handler produces output, you won't get it in the email.
Best regards,
-- Patrick
--
.------ Patrick M. Jordan ------. Random unused band name:
| Systems/Network Administrator | Snow Diddley and the Elves
`----- Antistatic Matrix -------'
-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
Mason-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mason-users