Skip to content

Commit

Permalink
fixed template inheritance bug in include helper
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Oct 28, 2013
1 parent f43a31d commit 5896bf9
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
1 change: 1 addition & 0 deletions Changes
Expand Up @@ -5,6 +5,7 @@
longer has any effect. (jberger, sri)
- Improved form_for performance.
- Improved built-in templates with documentation search.
- Fixed template inheritance bug in include helper.
- Fixed a few multipart form handling bugs.

4.50 2013-10-22
Expand Down
5 changes: 2 additions & 3 deletions lib/Mojolicious/Plugin/DefaultHelpers.pm
Expand Up @@ -64,8 +64,7 @@ sub _current_route {
sub _include {
my $self = shift;
my $template = @_ % 2 ? shift : undef;
my $args = {@_};
$args->{template} = $template if defined $template;
my $args = {@_, defined $template ? (template => $template) : ()};

# "layout" and "extends" can't be localized
my $layout = delete $args->{layout};
Expand All @@ -75,7 +74,7 @@ sub _include {
my @keys = keys %$args;
local @{$self->stash}{@keys} = @{$args}{@keys};

return $self->render(partial => 1, layout => $layout, extend => $extends);
return $self->render(partial => 1, layout => $layout, extends => $extends);
}

sub _url_with {
Expand Down
2 changes: 1 addition & 1 deletion lib/Mojolicious/Renderer.pm
Expand Up @@ -53,7 +53,7 @@ sub render {
my ($self, $c, $args) = @_;
$args ||= {};

# Localize "extends" and "layout"
# Localize "extends" and "layout" to allow argument overrides
my $stash = $c->stash;
local $stash->{layout} = $stash->{layout} if exists $stash->{layout};
local $stash->{extends} = $stash->{extends} if exists $stash->{extends};
Expand Down
8 changes: 4 additions & 4 deletions t/mojolicious/layouted_lite_app.t
Expand Up @@ -320,18 +320,18 @@ layout_with_template
Nested <%= include 'outerlayout' %>
@@ localized.html.ep
% layout 'localized1';
% extends 'localized1';
<%= $test %>
<%= include 'localized_partial', test => 321, layout => 'localized2' %>
<%= include 'localized_partial', test => 321, extends => 'localized2' %>
<%= $test %>
@@ localized_partial.html.ep
<%= $test %>
@@ layouts/localized1.html.ep
@@ localized1.html.ep
localized1 <%= content %>
@@ layouts/localized2.html.ep
@@ localized2.html.ep
localized2 <%= content %>
@@ outerlayout.html.ep
Expand Down

0 comments on commit 5896bf9

Please sign in to comment.