chrisdel101
Using the default liveView setup via the generator, the flash messages are in live.html.heex. These appear to be included in all true LV’s via MyAppWeb module. But they are not in any of the child components. Not sure why. I’ve been copy/pasting so far but that is not sustainable.
How can I import this live.html into the child components too? I can’t find any docs on that layout keyword used below, if this might be the key.
This is the default code that imports the flashes into the main liveViews.
#live.html.heex
<main class="container">
<p class="alert alert-info" role="alert"
phx-click="lv:clear-flash"
phx-value-key="info"><%= live_flash(@flash, :info) %></p>
# other flashes
<%= @inner_content %>
</main>
# myapp_web.ex
defmodule MyAppWeb do
def controller do ...
def view do ...
def live_view do
quote do
use Phoenix.LiveView,
# this imports the flashes live.html
layout: {MyApp.LayoutView, "live.html"}
unquote(view_helpers())
end
end
def live_component do
quote do
use Phoenix.LiveComponent,
# but this does not work - has no effect (I added this)
layout: {MyApp.LayoutView, "live.html"}
unquote(view_helpers())
end
end
...
Trending in Questions
Hello!
Suppose you are building workflow (order / task / payment) processing system with the following requirements:
Each workflow con...
New
I’m aware of 2 such projects, are there others?
git: GitHub - team-alembic/realworld: A fullstack Phoenix LiveView application with back...
New
Hi all,
I’m working on a Phoenix project where I need to make external HTTP requests and I’m trying to choose between Req and HTTPoison....
New
Hi everyone.
My team and I have been working on a fairly modest app based around video streaming and chat, but we’ve landed a customer t...
New
Hi,
we run different LLM models across a cluster, with each node loading a configurable subset. Model-specific queues let nodes consume ...
New
Hi all, I’m new here and would like to hear peoples views on my Elixir/Phoenix based game-engine! :smiley:
Mutonex gamedesign was finish...
New
Hello
I’ve been coding in Elixir for almost two years now because of my current job where we implemented Elixir in our application. But ...
New
Other Trending Topics
Hey there,
I haven’t seen a list of useful Elixir specific skills for the popular AI tools yet so I’m starting one here with my first.
...
New
I fully migrated to my own harness from Anthropic/Gemini and I think it’s time to share it. Welcome DSH, the DeepSeek Harness, fully writ...
New
Hey. Is there anyone here who creates agents in their apps? Not talking about using agents, but creating them. I’m finding it pretty diff...
New
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
With AI doing more of the implementation work, I’ve been wondering how much coding I should deliberately keep doing myself.
My main conc...
New
(I just needed to vent somewhere and LinkedIn is full of hope, or hype, I’m not sure which exactly)
AI dream has many faces, but general...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #library
- #deployment
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #podcasts
- #javascript
- #onsite
- #dialyzer
- #docker
- #authentication
- #ai
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #blog-post
- #ecto-query
- #elixirconf-us
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #elixirconf-eu
- #api
- #forms
- #security
- #hex











Showing Posts 1 to 3- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
100phlecs
Phoenix.LiveComponent doesn’t take
layout:as an option.I’m not sure of the structure of your app, but what you could do in order to not copy paste the flash html code around would be to wrap your livecomponents in a function that takes a slot.
Using the
embed_templatesmacro, you can then calllive.html.heexas a HEEx tag, i.e.Otherwise I would just copy paste it into a HEEx function within a module that is accessible within your live components:
chrisdel101
Even thought I just used the live view generator around 3 months ago it gave me version
17.5. Or maybe it was some online tutorial where I copy pasted the wrong version into my mix file.I’ve just tried to upgrade but I get error
error: undefined variable "f"in a million places. No idea how to fix that. So looks like I’m stuck with the old version.embed_templatesdoesn’t appear to be supported.Will give the slots way a try and reply if I fail.
Thx!
gerrit
You probably updated to LiveView 0.19.0 which removes the previously deprecated
let. You now have to use:letinstead.E.g.
<.form let={f} for={@changeset}>is replaced by<.form :let={f} for={@changeset}>