X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Runtime.git;a=blobdiff_plain;f=lib%2FCatalyst%2FManual%2FIntro.pod;h=32e2ba18e04088e87789341c325c2075c80b2393;hp=fe9ac8d200af4fcaf5095db720d037d8631d4072;hb=1c34f703cbd82cddceea95593001a579e1d5f646;hpb=d666af81cece84d49c57bb91949641937ad57091 diff --git a/lib/Catalyst/Manual/Intro.pod b/lib/Catalyst/Manual/Intro.pod index fe9ac8d..32e2ba1 100644 --- a/lib/Catalyst/Manual/Intro.pod +++ b/lib/Catalyst/Manual/Intro.pod @@ -425,20 +425,20 @@ and can be declared to expect an arbitrary number of arguments. The endpoint of the chain specifies how many arguments it gets through the C attribute. C<:Args(0)> would be none at all, C<:Args> without an integer would be unlimited. The path parts that aren't endpoints are using -C to specify how many parameters they expect to receive. As an +C to specify how many parameters they expect to receive. As an example setup: package MyApp::Controller::Greeting; use base qw/ Catalyst::Controller /; # this is the beginning of our chain - sub hello : PathPart('hello') Chained('/') Captures(1) { + sub hello : PathPart('hello') Chained('/') CaptureArgs(1) { my ( $self, $c, $integer ) = @_; $c->stash->{ message } = "Hello "; $c->stash->{ arg_sum } = $integer; } - # this is our endpoint, because it has no :Captures + # this is our endpoint, because it has no :CaptureArgs sub world : PathPart('world') Chained('hello') Args(1) { my ( $self, $c, $integer ) = @_; $c->stash->{ message } .= "World!"; @@ -464,12 +464,12 @@ an example of the startup output with our actions above: As you can see, Catalyst only deals with chains as whole path and builds one for each endpoint, which are the actions with C<:Chained> -but without C<:Captures>. +but without C<:CaptureArgs>. Let's assume this application gets a request at the path C, what happens then? First, Catalyst will dispatch to the C action and pass the value C<23> as argument to it after -the context. It does so because we have previously used C<:Captures(1)> +the context. It does so because we have previously used C<:CaptureArgs(1)> to declare that it has one path part after itself as it's argument. We told Catalyst that this is the beginning of the chain by specifying C<:Chained('/')>. Also note that instead of saying C<:PathPart('hello')> @@ -478,7 +478,7 @@ the action. After C has run, Catalyst goes on to dispatch to the C action. This is the last action to be called, as Catalyst knows this -is an endpoint because we specified no C<:Captures> attribute. Nevertheless +is an endpoint because we specified no C<:CaptureArgs> attribute. Nevertheless we specify that this action expects an argument, but at this point we're using C<:Args(1)> to do that. We could also have said C<:Args> or leave it out alltogether, which would mean this action gets all arguments that @@ -525,13 +525,13 @@ other. An example would be, for example, a wiki path like C. This chain can be easily built with these actions: - sub wiki : PathPart('wiki') Chained('/') Captures(1) { + sub wiki : PathPart('wiki') Chained('/') CaptureArgs(1) { my ( $self, $c, $page_name ) = @_; # load the page named $page_name and put the object # into the stash } - sub rev : PathPart('rev') Chained('wiki') Captures(1) { + sub rev : PathPart('rev') Chained('wiki') CaptureArgs(1) { my ( $self, $c, $revision_id ) = @_; # use the page object in the stash to get at it's # revision with number $revision_id @@ -557,7 +557,7 @@ C. If you want, for example, to have actions for the public paths C and C, just specify two actions with C<:PathPart('foo')> and C<:Chained('/')>. The handler for the former -path needs a C<:Captures(1)> attribute and a endpoint with +path needs a C<:CaptureArgs(1)> attribute and a endpoint with C<:PathPart('edit')> and C<:Chained('foo')>. For the latter path give the action just a C<:Args(1)> to mark it as endpoint. This sums up to this debugging output: @@ -606,7 +606,7 @@ itself to an action with the path of the current controllers namespace. For example: # in MyApp::Controller::Foo - sub bar : Chained Captures(1) { ... } + sub bar : Chained CaptureArgs(1) { ... } # in MyApp::Controller::Foo::Bar sub baz : Chained('.') Args(1) { ... } @@ -617,25 +617,25 @@ the path of the current controller namespace, namely C. That action chains directly to C, so the above chain comes out as end product. -=item Captures +=item CaptureArgs Also has to be specified for every part of the chain that is not an endpoint. With this attribute Catalyst knows how many of the following parts of the path (separated by C) this action wants to captures as -it's arguments. If it doesn't expect any, just specify C<:Captures(0)>. +it's arguments. If it doesn't expect any, just specify C<:CaptureArgs(0)>. The captures get passed to the action's C<@_> right after the context, but you can also find them as array reference in C<$c-Erequest-Ecaptures-E[$level]>. The C<$level> is the level of the action in the chain that captured the parts of the path. An action that is part of a chain (read: that has a C<:Chained> attribute) -but has no C<:Captures> attribute is treated by Catalyst as a chain end. +but has no C<:CaptureArgs> attribute is treated by Catalyst as a chain end. =item Args By default, endpoints receive the rest of the arguments in the path. You can tell Catalyst through C<:Args> explicitly how many arguments your -endpoint expects, just like you can with C<:Captures>. Note that this +endpoint expects, just like you can with C<:CaptureArgs>. Note that this also influences if this chain is invoked on a request. A chain with an endpoint specifying one argument will only match if exactly one argument exists in the path. @@ -645,7 +645,7 @@ C<0>. If you just say C<:Args> without any arguments, it is the same as leaving it out alltogether: The chain is matched independent of the number of path parts after the endpoint. -Just like with C<:Captures>, the arguments get passed to the action in +Just like with C<:CaptureArgs>, the arguments get passed to the action in C<@_> after the context object. They can also be reached through C<$c-Erequest-Earguments>.