CGI-Prototype
view release on metacpan or search on metacpan
lib/CGI/Prototype.pm view on Meta::CPAN
use CGI::Prototype;
CGI::Prototype->activate;
But this won't be very interesting. You'll want to subclass this
class in a C<Class::Prototyped>-style manner to override most of its
behavior. Slots can be added to add or alter behavior. You can
subclass your subclasses when groups of your CGI pages share similar
behavior. The possibilities are mind-boggling.
Within the templates, C<self> refers to the current controller. Thus,
you can define callbacks trivially. In your template, if you need some
data, you can pull it as a request:
[% my_data = self.get_some_big_data %]
which is supplied by simply adding the same slot (method or data) in
the controlling class:
sub get_some_big_data {
my $self = shift;
return $self->some_other_method(size => 'big');
t/02-CGIP-flow.t view on Meta::CPAN
#! perl
use Test::More no_plan;
require_ok 'CGI::Prototype';
my @callbacks = qw(prototype_enter prototype_leave
app_enter app_leave
control_enter control_leave
render_enter render_leave
respond_enter respond_leave);
my @TRACE;
my $RESPOND = "My::App::One";
{
package My::App;
@ISA = qw(CGI::Prototype);
t/02-CGIP-flow.t view on Meta::CPAN
sub dispatch {
shift->TRACE("dispatch", @_);
return 'My::App::One';
}
sub template {
\ (shift->reflect->package . ' template');
}
for my $m ("display", @callbacks) {
*{__PACKAGE__ . "::$m"} = sub {
shift->TRACE($m, @_);
}
}
}
{
package My::App::One;
@ISA = qw(My::App);
( run in 0.829 second using v1.01-cache-2.11-cpan-cdf2f3d4e48 )