sabo66

sabo66

Hello, it is possible to convert a String into Literal ?

# ex. convert "ThermostatLive" in an assigns into ThermostatLive

<%= live_render(@conn, @var) %>

Showing Posts 1 to 4

benwilson512

benwilson512

Author of Craft GraphQL APIs in Elixir with Absinthe

Hi @sabo66 do you mean into an atom? "ThermostatLive" is a literal string, ThermostatLive is a literal atom. Your code doesn’t show any literals it shows an assign which is basically a type of variable.

Converting strings to atoms can be dangerous if they’re based on user specified content. Where is your @var coming from?

sabo66

sabo66 OP

@var is coming from the mount of a LiveView
I would render LiveView into another LiveView using a menu and a assign variable (or params ?)

ex. Pet (principal LiveView)
- DogLive
- CatLive
- … (childs LiveView)

  def render(assigns) do
    ~H"""
     <nav>Menu</nav>
      <%= live_render(@socket, @var) %>
    """
  end

  def mount(_params, _sessions, socket) do 
    {:ok, socket |> assign(var: "DogLive")} #DogLive is the default child LiveView
  end
benwilson512

benwilson512

Author of Craft GraphQL APIs in Elixir with Absinthe

It is very unusual to want to nest liveviews. More commonly you would render different components (live or functional) under the same liveview, or alternatively for navigation it’s more common to have a common Nav component in your app.html.heex file.

sabo66

sabo66 OP

Hm okay, I’m starting with Phoenix I will see the LiveComponent thx

— All posts loaded —

Where Next? Top

Trending in Discussions Top

AstonJ
The obligatory hello world thread! Who are you and where are you from? :stuck_out_tongue:
4663 61218 595
New
cblavier
Hey there, It’s been more than a year since we started using LiveView as our main UI library and building a whole library of UI componen...
515 12931 101
New
raa-ziq
Hi everyone :waving_hand: I wanted to share something I’ve been building — NowBlind, a random chat app designed to help people discover ...
New
sntran
In my third year of college, around 2010, I found Erlang. A few years later, I found Elixir. I liked the ideas at once: many small proces...
New
gtcode
I’ve been tinkering with Lynx (by José) via hold_ledger. I used AI to write the code, a separate specification, the tests, and the Lean p...
New
AstonJ
A remark @Garrison made… ..has already inspired a thread for the technical side of reclaiming our internet, but there is of course anot...
New
ManuelGarcia
Hi everyone! I’m the developer of PaperForge, and I’ve been working on something alongside it that I’d like your opinion on. I’m conside...
New

Other Trending Topics Top

GenericJam
Edit: 2026 May 15 - This post is archived. Mob is alive!! Main docs: mob v0.7.11 — Documentation A bit of explanation for the slightly c...
261 13127 112
New
dominicletz
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
mudasobwa
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
OndrejValenta
(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
kip
Localize is the next generation localisation library for Elixir. Think of it as ex_cldr version 3.0. The first version will be released ...
New
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews