You can still compose them at arbitrary levels. Here is a pseudo-translation of your code to slots:
# any_regular_page.html.heex
<.base_layout>
Great stuff <%= name %>
</.base_layout>
# admin_helpers.ex
def admin_sidebar(assigns) do
~H"""
<ul>
<%= for entry <- @entries %>
<li><%= entry %></li>
<% end %>
</ul>
"""
end
def admin_layout(assigns) do
~H"""
<.base_layout>
<:additional_navbar>
<li>admin navbar entry</li>
</:additional_navbar>
<.admin_sidebar />
<%= render_slot(@inner_block) %>
</.base_layout>
"""
end
# any_admin.page.html.heex
<.admin_layout>
This is my great admin content
</.admin_layout>
You still need to pick one layout at the top, but that’s the same with template inheritance. Still, slots can be more structured, and they allow at the composition to happen at any moment, not only from the template you are inheriting.


















