Nesting layouts fails
#2139
-
A few sources have told me that Mojolicious supports nested layouts, but these don't appear to work. The log indeed reports loading both templates, however the result only renders the topmost template. If I'm doing something wrong here any pointers would be helpful. Steps to reproduce the behavior$ mojo generate lite-app nesting.pl
...
$ cat nesting.pl
#!/usr/bin/env perl
use Mojolicious::Lite -signatures;
get '/' => sub ($c) {
$c->render(template => 'index');
};
app->start;
__DATA__
@@ index.html.ep
% layout 'main';
% title 'Welcome';
<h1>Welcome to the Mojolicious real-time web framework!</h1>
@@ layouts/default.html.ep
<!DOCTYPE html>
<html>
<head><title><%= title %></title></head>
<body><%= content %></body>
</html>
@@ layouts/main.html.ep
% layout 'default';
<main>
<%= content %>
</main>
<footer>
This content is the footer.
</footer>
$ morbo nesting.pl Expected behavior
Actual behavior
|
Beta Was this translation helpful? Give feedback.
Answered by
kraih
Dec 29, 2023
Replies: 1 comment 1 reply
-
We don't currently support layouts within layouts. Perhaps what you're looking for is really template inheritance. https://docs.mojolicious.org/Mojolicious/Guides/Rendering#Template-inheritance |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
rnkn
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
We don't currently support layouts within layouts. Perhaps what you're looking for is really template inheritance. https://docs.mojolicious.org/Mojolicious/Guides/Rendering#Template-inheritance