6
votes

I'm using Elixir in Phoenix framework.We know when we call an action in controller, the framework render a full view that includes footer, inner view ( main content) and header. How to load and render just a view without header, footer view ?

Example : localhost:4000/posts/new -> We will have header, form and footer

localhost:4000/post/1 -> We just show content of post #1 without header and footer view.

Thanks,

1

1 Answers

11
votes

You need to use Phoenix.Controller.put_layout(conn, false) in your controller action function to disable rendering the layout, e.g.

def show(conn, _params) do
  conn
  |> put_layout(false)
  |> render("show.html")
end