In the Elixir IRC, josevalim
refers to a way to compose templates in Phoenix, by defining and then using a layout helper, as such:
<%= with_layout Layout, "app..." do %>hello<% end %>
I'm very new to Phoenix, but I'm assuming the with_layout
helper is defined in the view corresponding to the template above, but I can't figure out where/how to define and/or access this Layout
. I'm familiar now with "templates" and "views", but can't find much info on Phoenix layouts or layout helpers.
So my question is, what exactly does Layout
refer to here, and how do Phoenix "layouts" differ from "templates"?
That conversation is very old by Phoenix standards. I don't think it is valid anymore, not even I know what it means. ;)
If you want to render something with a layout, you just need to call in your views:
render(YourApp.UserView, "index.html",
layout: {YourApp.LayoutView, "app.html"})
The LayoutView is the one Phoenix generates by default in your apps. You can read more about this in Phoenix docs: http://hexdocs.pm/phoenix/Phoenix.View.html#render/3
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With