Skip to content

Commit

Permalink
mention how to make stash values special
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Oct 12, 2015
1 parent e8f9a0e commit 23c5ca6
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion lib/Mojolicious/Guides/Rendering.pod
Expand Up @@ -1442,10 +1442,21 @@ generating bytes instead.
return 1;
});

get '/' => {storable => {i => '♥ mojolicious'}, handler => 'storable'};
# Set "handler" value automatically if "storable" value is set already
app->hook(before_render => sub {
my ($c, $args) = @_;
$args->{handler} = 'storable'
if exists $args->{storable} || exists $c->stash->{storable};
});

get '/' => {storable => {i => '♥ mojolicious'}};

app->start;

The hook L<Mojolicious/"before_render"> can be used to make stash values like
C<storable> special, so that they no longer require a C<handler> value to be set
explicitly.

=head1 MORE

You can continue with L<Mojolicious::Guides> now or take a look at the
Expand Down

0 comments on commit 23c5ca6

Please sign in to comment.