Gilou06

Gilou06

Layout and LiveView 0.10.0

I have started developping with Liveview 0.5.1 and recently switched to 0.10.1
I don’t understand well the changelog :" (…)Therefore, we recommend setting put_root_layout in a pipeline that is exclusive to LiveViews"
I understand that root layout is top-level, shared among live and no-live views. The changelog seems to say that that should no longer be the case. If I put put_root_layout to a LiveView dedicated pipeline, it won’t be set for regular view pipe-lines, meaning regular views won’t have a root layout anymore.
Since I could not make my mind with doc and changelog, I went away and altered my code until it “worked accidentely”.
Please tell me if what I did is correct.

1/I set

plug :put_root_layout, {MsimWeb.LayoutView, :root}
in the main pipeline in router.ex

2/My previously empty root.html.eex now contains whatever was in app.html.eex, and I changed the render… to @inner_content

3/My app.html.eex is now almost empty, it has a one line render…

4/ My previously empty live.html has now few lines about live_flash and is called by altering each liveview file with

use Phoenix.LiveView, layout: {MsimWeb.LayoutView, “live.html”}

Thanks for your help

First Post!

sfusato

sfusato

Here’s how phx.gen.live generated templates look like in phoenix master. Your changes are on line with the default setup.

Live Layouts part of the LiveView docs expands on this.

Last Post!

Gilou06

Gilou06

Thank you
I read the Live View doc and used it to make my code work. However, can you explain the apparent contradiction between this doc and the changelog ? The item that bugs me is this recomendation in the changelog about not to use the root layout for all views.

Where Next?

Popular in Questions Top

vegabook
I’m brand new to Phoenix and I have stripped one of the demo applications to the bone. I just want to get an svg up on the screen. Here i...
New
jononomo
I am trying to figure out how Mix knows whether the environment is test, dev, or prod – where is this set? Thanks.
New
lanycrost
Hi everyone! I need implement if…else if…else condition from my elixir code, and anymore of this control flow structures not work proper...
New
openscript
Hello! Sorry for this astonishing simple question, but I’m really stuck. I try to set up the intellij-elixir plugin, but I don’t know ho...
New
stefanchrobot
What’s the safe way to decode a JSON string into a struct? I want to avoid calling String.to_atom. Jason.decode can give me a map with st...
New
sergio_101
I am VERY much an elixir newbie. I have taken one elixir course and one phoenix course on Udemy. During that course, I saw the instructor...
New
shijith.k
I am trying to start a new phoenix project with elixir 1.9, but mix phx.new does not work. It says that ** (Mix) The task "phx.new" could...
New

Other popular topics Top

sergio_101
I am VERY much an elixir newbie. I have taken one elixir course and one phoenix course on Udemy. During that course, I saw the instructor...
New
shijith.k
I am trying to start a new phoenix project with elixir 1.9, but mix phx.new does not work. It says that ** (Mix) The task "phx.new" could...
New
AngeloChecked
What learn first? Rust or Elixir Hi Elixir community! I’m here because i want learn a new language. I’m a junior developer and mainly i ...
New
albydarned
Hello all! I am typing this post from my new MacBook Pro with the M1 chip. I’m loving it so far, and will probably use it as my daily dr...
New
senggen
Erlang/OTP 25 [erts-13.2.2] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] 15:22:35.803 [error] gen_event {lager_file_backend...
New
AstonJ
Posting this to see if we can make things easier for people to get into Neovim. If you use Neovim and have a favourite distro please let ...
New

We're in Beta

About us Mission Statement