Skip to content

Commit

Permalink
Remove documentation for deprecated before/before_template/after
Browse files Browse the repository at this point in the history
Replace detailed docs with a pointer to the hook keyword.
  • Loading branch information
bigpresh committed Feb 16, 2012
1 parent 2c9c790 commit b9ee2ec
Showing 1 changed file with 3 additions and 55 deletions.
58 changes: 3 additions & 55 deletions lib/Dancer.pm
Original file line number Diff line number Diff line change
Expand Up @@ -599,21 +599,7 @@ The above would import all keywords as normal, with the exception of C<session>.
=head2 after
Add a hook at the B<after> position:
after sub {
my $response = shift;
# do something with response, e.g.:
$response->header('X-Beer' => 'Yes please');
};
The anonymous function which is given to C<after> will be executed after
having executed a route, but before the response is returned (so you can modify
the response here, if you need to)..
You can define multiple after filters, using the C<after> helper as
many times as you wish; each filter will be executed, in the order you added
them.
Deprecated - see the C<after> L<hook|Dancer/hook>.
=head2 any
Expand All @@ -631,49 +617,11 @@ Or even, a route handler that would match any HTTP methods:
=head2 before
Defines a before filter:
before sub {
# do something with request, vars or params
};
The anonymous function given to C<before> will be executed before executing a
route handler to handle the request. It will receive a reference to the route
handler about to be executed as its parameter.
If the function modifies the request's C<path_info> or C<method>, a new
search for a matching route is performed and the filter is re-executed.
Considering that this can lead to an infinite loop, this mechanism
is stopped after 10 times with an exception.
The before filter can set a response with a redirection code (either
301 or 302): in this case the matched route (if any) will be ignored and the
redirection will be performed immediately.
You can define multiple before filters, using the C<before> helper as
many times as you wish; each filter will be executed in the order you added
them.
Deprecated - see the C<before> L<hook|Dancer/hook>.
=head2 before_template
Defines a before_template filter:
before_template sub {
my $tokens = shift;
# do something with request, vars or params
# for example, adding a token to the template
$tokens->{token_name} = "some value";
};
The anonymous function which is given to C<before_template> will be executed
before sending data and tokens to the template. Receives a HashRef of the
tokens that will be inserted into the template.
This filter works as the C<before> and C<after> filter.
Now the preferred way for this is to use C<hook>s (namely, the
C<before_template> one). Check C<hook> documentation below.
Deprecated - see the C<before_template> L<hook|Dancer/hook>.
=head2 cookies
Expand Down

0 comments on commit b9ee2ec

Please sign in to comment.