Skip to content

Commit

Permalink
a few more controller examples
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Jan 8, 2012
1 parent a31ad8c commit 45203be
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion Changes
@@ -1,6 +1,6 @@
This file documents the revision history for Perl extension Mojolicious.

2.44 2012-01-08 00:00:00
2.44 2012-01-09 00:00:00
- Improved documentation.

2.43 2012-01-08 00:00:00
Expand Down
22 changes: 11 additions & 11 deletions lib/Mojolicious/Controller.pm
Expand Up @@ -24,12 +24,10 @@ has tx => sub { Mojo::Transaction::HTTP->new };
# Bundled files
my $H = Mojo::Home->new;
$H->parse($H->parse($H->mojo_lib_dir)->rel_dir('Mojolicious/templates'));
our $EXCEPTION = $H->slurp_rel_file('exception.html.ep');
our $DEVELOPMENT_EXCEPTION =
$H->slurp_rel_file('exception.development.html.ep');
our $NOT_FOUND = $H->slurp_rel_file('not_found.html.ep');
our $DEVELOPMENT_NOT_FOUND =
$H->slurp_rel_file('not_found.development.html.ep');
our $EXCEPTION = $H->slurp_rel_file('exception.html.ep');
our $DEV_EXCEPTION = $H->slurp_rel_file('exception.development.html.ep');
our $NOT_FOUND = $H->slurp_rel_file('not_found.html.ep');
our $DEV_NOT_FOUND = $H->slurp_rel_file('not_found.development.html.ep');

# Reserved stash values
my @RESERVED = (
Expand Down Expand Up @@ -300,7 +298,7 @@ sub render_exception {
exception => $e,
'mojo.exception' => 1
};
my $inline = $mode eq 'development' ? $DEVELOPMENT_EXCEPTION : $EXCEPTION;
my $inline = $mode eq 'development' ? $DEV_EXCEPTION : $EXCEPTION;
return if $self->_render_fallbacks($options, 'exception', $inline);
$options->{format} = 'html';
$self->_render_fallbacks($options, 'exception', $inline);
Expand Down Expand Up @@ -343,7 +341,7 @@ sub render_not_found {
guide => $guide,
'mojo.not_found' => 1
};
my $inline = $mode eq 'development' ? $DEVELOPMENT_NOT_FOUND : $NOT_FOUND;
my $inline = $mode eq 'development' ? $DEV_NOT_FOUND : $NOT_FOUND;
return if $self->_render_fallbacks($options, 'not_found', $inline);
$options->{format} = 'html';
$self->_render_fallbacks($options, 'not_found', $inline);
Expand Down Expand Up @@ -681,6 +679,8 @@ controller, defaults to a L<Mojolicious> object.
Routes dispatcher results for the current request, defaults to a
L<Mojolicious::Routes::Match> object.
my $name = $c->match->endpoint->name;
=head2 C<tx>
my $tx = $c->tx;
Expand Down Expand Up @@ -807,8 +807,8 @@ C<extends> features.
=head2 C<render_data>
$c->render_data($bits);
$c->render_data($bits, format => 'png');
$c->render_data($bytes);
$c->render_data($bytes, format => 'png');
Render the given content as raw bytes, similar to C<render_text> but data
will not be encoded.
Expand All @@ -824,7 +824,7 @@ C<exception.$format.*> and set the response status code to C<500>.
=head2 C<render_json>
$c->render_json({foo => 'bar'});
$c->render_json([1, 2, -3]);
$c->render_json([1, 2, -3], status => 201);
Render a data structure as JSON.
Expand Down

0 comments on commit 45203be

Please sign in to comment.