How to load views/templates inside each other

Hi, I’m new to Phoenix and Elixir and I’m still a bit confused on how I load views/templates into each other. Where I can have shared components.

I have my main layout “app.html.eex” which loads the correct template via <%= render @view_module, @view_template, assigns %> which is great and is loaded via the controller and router but I would like to have a global nav bar and footer that can be used across my public pages.

How is this done?

<div class="wrapper" id="wrapper">
  <%= render "_header.html", conn: @conn %>
  <!--Main layout-->
    <!--Main container-->
    <div class="container-fluid">
      <%= render @view_module, @view_template, assigns %>
    <!--Main container-->
  <!--Main layout-->
  <%= render "_footer.html",        conn: @conn %>
</div><!--wrapper end-->
1 Like

That was the first thing I tried but I’m getting

(Phoenix.Template.UndefinedError) Could not render “_header.html” for MagnifyWeb.LayoutView, please define a matching clause for render/2 or define a template at “lib/magnify_web/templates/layout”. The following templates were compiled:

I believe maybe I’m missing a step?

Ok got it working, the following helped me understand everything thanks for the help -