X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FCatalyst%2FManual%2FIntro.pod;h=6ba61e38a9e872f1220be7bd64863607cf1a21fd;hb=a74c2d1a1e12c43e5dbb4caef23f7cc25e57bd1f;hp=21a701d22b509352faa6b6a0b1986cab53cb43d5;hpb=5882c86e1f256e122583dcc311b17bdbf9a4d766;p=catagits%2FCatalyst-Runtime.git diff --git a/lib/Catalyst/Manual/Intro.pod b/lib/Catalyst/Manual/Intro.pod index 21a701d..6ba61e3 100644 --- a/lib/Catalyst/Manual/Intro.pod +++ b/lib/Catalyst/Manual/Intro.pod @@ -417,91 +417,6 @@ C<$c-Ereq-Ecaptures-E[0]> would be "23". If you want to pass arguments at the end of your URL, you must use regex action keys. See L below. -=item * B - - sub section :PathPart('section') :Chained('/') :Captures(1) { } - -Chained is a powerful way to handle canonical URIs of the form -C. Using this URI as an example, -in Controller::Root you can do the following: - - sub section_handler :PathPart('section') :Chained('/') :Captures(1) { - my ( $self, $c ) = @_; - $c->stash->{'section'} = - $c->Model('Sections')->find($c->req->captures->[0]); - } - - sub item_handler :PathPart('item') :Chained('/section_handler') :Args(1) { - my ( $self, $c ) = @_; - $c->stash->{'item'} = - $c->stash->{'section'}->find_related('item',$c->args->[0]); - } - -The subroutine C matches the path segment "section" as -a child of "/". It then takes the next path segment, as referenced by -C<:Captures(1)>, and stashes it in the arrayref -C<$c-Ereq-Ecaptures>. Since there is also a child of this -handler, it also gets run, functioning in the same way. However, the -C subroutine has the C attribute which means this -particular routine will only run if there is exactly one argument. See -L below for more options. - -A parent action can be in any controller or namespace. - -Multiple actions can specify the same parent action in their C; -that is, one action can have multiple children. - -=item Chained('xyz') - -The action of the parent. For instance, if you have a method -C in the controller C, the action -would be C. For a Root handler this -would be '/'. For an action in the same controller namespace you can use -a relative name like C<:Chained('foo')>. - -=item PathPart('xyz') - -The name of this path section in the Chained tree mapping to the URI. If -you specify C<:PathPart> without arguments, it takes the name of the -action specifying the argument. For example, these two declarations -have the same effect: - - sub foo :PathPart('foo') :Chained('bar') :Args(1) { - ... - } - -and - - sub foo :PathPart :Chained('bar') :Args(1) { - ... - } - -The value can also contain a slash, for example: - - sub baz :PathPart('bar/baz') :Chained('/') :Captures(1) { - ... - } - -would be involved in matches on C paths. - -=item Captures(integer) - -Will 'collapse' the next C path segments in the request URI and -push them into the arrayref C<$c-Ereq-Ecaptures>. An action -specifying C is thought to be used as target for C -specifications. Also see the C attribute below, which is used for -endpoints. - -=item Args(int) - -The number of path segments to capture at the end of a request URI. This -B be included in your leaf nodes. You can use C for an -equivalent of the index action. Args with no parameters will capture -every postfixed segment into C<$c-Ereq-Eargs>. - -A specification of C is seen as endpoint in regard to an additional -C specification. - =item * B (B) package MyApp::Controller::Foo; @@ -529,6 +444,24 @@ Catalyst ("MyApp::Controller" in the above example), replaces "::" with explanation of the pre-defined meaning of Catalyst component class names. +=item * B + +Catalyst also provides a method to build and dispatch chains of actions, +like + + sub foo : Chained : CaptureArgs(1) { + my ( $self, $c, $arg ) = @_; + ... + } + + sub bar : Chained('foo') : Args(1) { + my ( $self, $c, $arg ) = @_; + ... + } + +to handle a C path. For more information about this dispatch +type, please read L. + =item * B sub foo : Private { } @@ -898,7 +831,8 @@ C<$c-Eforward(qw/MyApp::View::TT process/)>. } You normally render templates at the end of a request, so it's a perfect -use for the global C action. +use for the global C action. (In practice, however, you would use a +default C action as supplied by L.) Also, be sure to put the template under the directory specified in C<$c-Econfig-E{root}>, or you'll be forced to look at our