Egg::Plugin::Mason - Plugin for Egg::View::Mason
package MyApp; use Egg qw/ Mason Net::Scan MailSend FillInForm /;
Example template
<%init> my $ms= $e->mason->prepare( page_title => 'Hoge', no_cache => 1, commit_ok => 1, ); $ms->code_first(sub { my $scan= $e->port_scan(qw/ 192.168.1.1 25 /); return 0 if $scan->is_success; $ms->complete('Mail host is stopping.'); }); $ms->code_action(sub { $e->referer_check(1) || return 0; ............ .... $e->mail->send; $ms->complete('Mail was sent.'); }); $ms->code_final(sub { $e->fillin_ok(1); }); $ms->exec; </%init> % <html> <body> % if ($ms->is_complete) { <h1><% $ms->complete_topic %></h1> % } else { <form method="POST" action= ...... > ......... .... </form> % } # $ms->complete end. </body> </html>
It is a plugin convenient when using it with the template of HTML::Mason.
First of all, a basic setting is done by the prepare method.
And, the code reference defined to 'code_first', 'code_action', 'code_final' as call the exec method is evaluated and processing is completed.
Egg::Plugin::Mason::handler ¥ª¥Ö¥¸¥§¥¯¥È¤òÊÖ¤·¤Þ¤¹¡£
Egg::Base has been succeeded to.
Prior is set.
As for ATTR_HASH, the following keys are accepted.
my $ms= $e->mason->prepare( page_title => 'home page', expires => '+1D', );
page_title
It is a character string set to $e->page_title.
no_cache
$e->response->no_cache is set.
expires
$e->response->is_expires and $e->response->last_modified are set.
commit_ok
$e->dbh->commit_ok is done.
Only being able to use Egg::Model::DBI is effective.
code_first, code_action, code_final
The code reference processed with exec is set.
The code of code_first, code_action, and code_final set beforehand is processed.
When undefined is returned, each code interrupts processing by the code.
$e->exec;
Accessor to code reference to process it with exec.
The completion message etc. are set and '1' is returned.
The default when TOPIC_STR is not obtained is 'Complete !!'.
The default when INFO_STR is not obtained is '<p class="info"><a href="/">Please click.</p>'.
$e->complete('is completed', <<END_INFO); <a href="/">It returns to top page.</a> END_INFO
The completion message etc. are set and 0 is returned.
The default when TOPIC_STR is not obtained is 'Sorry !!'.
Default when INFO_STR is not obtained is '<p class =" info "><a href ="/">Please click.</p>'.
my $data= $e->get_data || return $e->error_complete('is error.', <<END_INFO); <h2>The error occurred.</h2> <p><a href="/">It returns to top page.</a></p> END_INFO
If 'complete' method is called, it becomes effective.
If 'error_complete' method is called, it becomes effective.
The first argument of 'complete' method or 'error_complete' method is set.
The second argument of 'complete' method or 'error_complete' method is set.
Egg::Release, Egg::Base, HTML::Mason,
Masatoshi Mizuno <lushe@cpan.org>
Copyright (C) 2008 Bee Flag, Corp. <http://egg.bomcity.com/>, All Rights Reserved.
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.6 or, at your option, any later version of Perl 5 you may have available.
1 POD Error
The following errors were encountered while parsing the POD:
Non-ASCII character seen before =encoding in '¥ª¥Ö¥¸¥§¥¯¥È¤òÊÖ¤·¤Þ¤¹¡£'. Assuming CP1252
To install Egg::Release, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Egg::Release
CPAN shell
perl -MCPAN -e shell install Egg::Release
For more information on module installation, please visit the detailed CPAN module installation guide.