blset

blset

Pdf prinf live component

when trying to manually render a liveview for subsequent pdf print I get
an error when a live component is in the liveview render template

using this

assigns_map
|> LiveViewModule.render()
|> Phoenix.HTML.Safe.to_iodata()
|> to_string()

with assign_map containing all necessary assigns for the live view

with a liveview with render function containing another live component like

~H"“”
<.other_live_component …>
“”"
the error message is

** (ArgumentError) cannot convert component OtheLiveComponent with id 116158 to HTML.

A component must always be returned directly as part of a LiveView template.
For example, this is not allowed:

<%= content_tag :div do %>
  <.live_component module={SomeComponent} id="myid" />
<% end %>

That’s because the component is inside content_tag. However, this works:

<div>
  <.live_component module={SomeComponent} id="myid" />
</div>

Components are also allowed inside Elixir’s special forms, such as
if, for, case, and friends.

<%= for item <- items do %>
  <.live_component module={SomeComponent} id={item} />
<% end %>

However, using other module functions such as Enum, will not work:

<%= Enum.map(items, fn item -> %>
  <.live_component module={SomeComponent} id={item} />
<% end %>

Now if I call directly Other_live_component, it works ok.
I’m not in any of the cases excluded by error message explanation

Where Next?

Popular in Questions Top

hariharasudhan94
Lets say I have map like this fetching from my database %{"_id" =&gt; #BSON.ObjectId&lt;58eb1a7a9ad169198c3dXXXX&gt;, "email" =&gt; ...
New
dokuzbir
I want to highlight html closing tags when i click a html tag. That works in .html files but doesnt work for html.eex templates. How can...
New
Darmani72
If I have a post route which an argument: post /my_post_route/:my_param1, MyController.my_post_handler How would get the post params ...
New
sen
Hi All, I set a environment variables in dev.exs , like below code. when i start server, how can i set the ${enable} value? thanks. d...
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
pmjoe
I have a relationship of love and hate with Elixir. Lots of things are just absolutely right, but there are some things that are kind of ...
New
romenigld
I am trying to run a deploy with docker and I successfully runned with this command: docker build -t romenigld/blog-prod . but when I t...
New

Other popular topics Top

KronicDeth
Elixir plugin for JetBrain’s IntelliJ Platform (including Rubymine) This is a plugin that adds support for Elixir to JetBrains IntelliJ...
289 36820 110
New
minhajuddin
I have seen a lot of code which picks the first element from a list using Enum.at(0) instead of List.first. Is there a reason why people ...
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
dokuzbir
I want to highlight html closing tags when i click a html tag. That works in .html files but doesnt work for html.eex templates. How can...
New
sen
Hi All, I set a environment variables in dev.exs , like below code. when i start server, how can i set the ${enable} value? thanks. d...
New
msaraiva
Surface is an experimental library built on top of Phoenix LiveView and its new LiveComponent API that aims to provide a more declarative...
564 44265 214
New

We're in Beta

About us Mission Statement