=head1 NAME
Reaction::Manual::Tutorial.pod - Step by Step Tutorial
=head1 DESCRIPTION
This document aims at giving simple step-by-step leading to an example application
using the common functionality provided by L.
=head1 CREATING A NEW APPLICATION
At first we have to create a new application. For this we use the C
script as we would for any other Catalyst application:
$ catalyst.pl MyApp
[lots "created ..." messages]
There is nothing to change in the application class file.
=head1 THE VIEW
Since we are not just rendering templates with Reaction, but layouts and widgets,
a simple TT view won't suffice. We need to create our own C:
package MyApp::View::Site;
use Reaction::Class;
use namespace::clean -except => 'meta';
extends 'Reaction::UI::View::TT';
__PACKAGE__->meta->make_immutable;
1;
The C. That means, you
can take a look at the layout we are extending at C
in the L distribution.
The C<=for layout> directives allows us to set a layout fragment. We define a C fragment
containing the common C for all pages using this site layout. The C<[% inner %]> is
where the deeper parts of the stack will be included, in the case of our C action that
would be the C with the C layout.
If we wanted to override a specific fragment, we could do just that. And inside that fragment
we could call C<[% next_call %]> to include the layout fragment from the extended layout.
The layout representing the root action is called C:
=for layout widget
Hello, World!
=cut
This one is rather simple. The C<=for layout widget> directive is special in that the
C fragment will always be where the rendering starts. In fact, our C
layout too contains a C fragment, you just don't see it because you inherited it from
your base skin (or your base skin's base skin, for that matter) instead of defining it yourself.
=head1 A SIMPLE WIDGET
If we wanted to use a different kind of widget than that assumed automatically by Reaction, we
could add a
=widget ClassName
directive at the top of the layout file. But for now, we will instead create our own
widget at C:
package MyApp::View::Site::Widget::Root;
use Reaction::UI::WidgetClass;
use namespace::clean -except => 'meta';
__PACKAGE__->meta->make_immutable;
1;
This adds no new functionality at the moment. It just uses C to ease
and automate the setup of a new widget class. The widget can provide functionality and fragments
to the layout. In a way, it can be seen as the Perl code backend to the layout file.
You can now start your C