I had some productive chats tonight #cgiapp on irc.perl.org.
I also enjoyed watching the 2nd Ruby on Rails movie:
http://www.rubyonrails.org/media/video/rails_take2_with_sound.mov
It's good marketing. People who won't read documentation for 5 minutes
will watch a 5 minute movie, and possibly get more out of it by
listening and watching at the same time. CGI:App should consider it's
own movie to capture the current developments.
The movie highlights how little syntax it takes to build custom web
apps. In that vein, I want to highlight some changes that can be made
to the standard CGI::App flow to use less syntax. This /almost works/.
We need some minor changes to support all this, but the key parts are
there.
Watch as I trim a 20 line CGI::App down to 10 lines:
sub setup {
my $self = shift;
$self->start_mode('first');
$self->run_modes([qw/
first
second
/]);
}
sub first {
my $self = shift;
return $self->second();
}
sub second {
my $self = shift;
my $t = $self->tmpl->load('second.html');
my %goodness;
$t->fill(\%goodness);
}
######
After:
# setup() is gone, and AnyTemplate and AutoRunMode plugins have been loaded.
sub first : StartRunmode {
my $self = shift;
return $self->forward('second');
}
sub second : Runmode {
my $self = shift;
my %goodness;
# Fills second.html, based on the current run mode name.
return $self->tmpl->fill(\%goodness);
}
###
AnyTemplate can figures out the file name for you, and uses the template
engine of your choice, or if you are distributing your app, your users
can choose!
* An implementation note: I recommend that the forward() method exist
at least of now in AnyTemplate and be documented only be used in this
kind of 'return' context. It's value is that it updates the current
runmode as it moves the flow along. That's all.
Mark
--
http://mark.stosberg.com/
---------------------------------------------------------------------
Web Archive: http://www.mail-archive.com/suppressed/
http://marc.theaimsgroup.com/?l=cgiapp&r=1&w=2
To unsubscribe, e-mail: suppressed
For additional commands, e-mail: suppressed
Mail converted by mhonarc 2.6.15
This archive provided courtesy of JSW4.NET, Internet Hosting Services for Small Business.