Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nesting layouts fails #2138

Closed
rnkn opened this issue Dec 29, 2023 · 0 comments
Closed

Nesting layouts fails #2138

rnkn opened this issue Dec 29, 2023 · 0 comments

Comments

@rnkn
Copy link

rnkn commented Dec 29, 2023

  • Mojolicious version: 9.35, Waffle
  • Perl version: v5.38.2
  • Operating system: macOS 14.2.1 (23C71)

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

$ curl 127.0.0.1:3000
<!DOCTYPE html>
<html>
  <head><title>Welcome</title></head>
<main>
  <body><h1>Welcome to the Mojolicious real-time web framework!</h1>
</main>
<footer>
This is the footer content.
</footer>
</body>
</html>

Actual behavior

$ curl 127.0.0.1:3000
<!DOCTYPE html>
<html>
  <head><title>Welcome</title></head>
  <body><h1>Welcome to the Mojolicious real-time web framework!</h1>
</body>
</html>
@mojolicious mojolicious locked and limited conversation to collaborators Dec 29, 2023
@kraih kraih converted this issue into discussion #2139 Dec 29, 2023

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant