Phoenix.View.render_layout
You're seeing just the function
render_layout
, go back to Phoenix.View module for more information.
Renders the given layout passing the given do/end
block
as @inner_content
.
This can be useful to implement nested layouts. For example, imagine you have an application layout like this:
# layout/app.html.eex
<html>
<head>
<title>Title</title>
</head>
<body>
<div class="menu">...</div>
<%= @inner_content %>
</body>
This layout is used by many parts of your application. However, there is a subsection of your application that wants to also add a sidebar. Let's call it "blog.html". You can build on top of the existing layout in two steps. First, define the blog layout:
# layout/blog.html.eex
<%= render_layout LayoutView, "app.html", assigns do %>
<div class="sidebar">...</div>
<%= @inner_content %>
<% end %>
And now you can simply use it from your controller:
plug :put_layout, "blog.html"