NAME
Egg::Plugin::Mason - Plugin for Egg::View::Mason
SYNOPSIS
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>
DESCRIPTION
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.
METHODS
mason
Egg::Plugin::Mason::handler ¥ª¥Ö¥¸¥§¥¯¥È¤òÊÖ¤·¤Þ¤¹¡£
HANDLER METHODS
Egg::Base has been succeeded to.
prepare ([ATTR_HASH])
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.
exec
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;
code_first, code_action, code_final
Accessor to code reference to process it with exec.
complete ([TOPIC_STR], [INFO_STR])
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
error_complete ([TOPIC_STR], [INFO_STR])
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
is_complete
If 'complete' method is called, it becomes effective.
is_error
If 'error_complete' method is called, it becomes effective.
complete_topic
The first argument of 'complete' method or 'error_complete' method is set.
complete_info
The second argument of 'complete' method or 'error_complete' method is set.
SEE ALSO
Egg::Release, Egg::Base, HTML::Mason,
AUTHOR
Masatoshi Mizuno <lushe@cpan.org>
COPYRIGHT AND LICENSE
Copyright (C) 2008 Bee Flag, Corp. <http://egg.bomcity.com/>.
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:
- Around line 133:
Non-ASCII character seen before =encoding in '¥ª¥Ö¥¸¥§¥¯¥È¤òÊÖ¤·¤Þ¤¹¡£'. Assuming CP1252