Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
fixed small assignment bug in content helper
  • Loading branch information
kraih committed Oct 20, 2013
1 parent df27d5a commit 4f9c91e
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
1 change: 1 addition & 0 deletions Changes
Expand Up @@ -2,6 +2,7 @@
4.50 2013-10-20
- Removed deprecated attrs method from Mojo::DOM.
- Improved Mojo::Message to allow max_message_size check to be disabled.
- Fixed small assignment bug in content helper.

4.49 2013-10-17
- Added tls_ciphers option to Mojo::IOLoop::Server::listen.
Expand Down
5 changes: 3 additions & 2 deletions lib/Mojolicious/Plugin/DefaultHelpers.pm
Expand Up @@ -41,7 +41,7 @@ sub _content {

# Set (first come)
my $c = $self->stash->{'mojo.content'} ||= {};
$c->{$name} ||= ref $content eq 'CODE' ? $content->() : $content
$c->{$name} //= ref $content eq 'CODE' ? $content->() : $content
if defined $content;

# Get
Expand Down Expand Up @@ -135,7 +135,8 @@ Alias for L<Mojo/"config">.
Store partial rendered content in named buffer and retrieve it, defaults to
retrieving the named buffer C<content>, which is commonly used for the
renderers C<layout> and C<extends> features.
renderers C<layout> and C<extends> features. Note that new content will be
ignored if the named buffer is already in use.
=head2 content_for
Expand Down
7 changes: 7 additions & 0 deletions t/mojolicious/layouted_lite_app.t
Expand Up @@ -107,6 +107,13 @@ get '/data' => {data => 0};

my $t = Test::Mojo->new;

# "0" content reassignment
my $c = $t->app->controller_class->new(app => $t->app);
$c->content(foo => '0');
is $c->content('foo'), '0', 'right content';
$c->content(foo => '1');
is $c->content('foo'), '0', 'right content';

# Template with layout
$t->get_ok('/works')->status_is(200)
->content_type_is('text/html;charset=UTF-8')
Expand Down

0 comments on commit 4f9c91e

Please sign in to comment.