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

jononomo
I am trying to figure out how Mix knows whether the environment is test, dev, or prod – where is this set? Thanks.
New
Emily
I have VueJS GUIs with the project generated using Webpack. I have Elixir modules that will need to be used by the VueJS GUIs. I forese...
New
skosch
To my knowledge, put_in, Map.update etc. all have the one limitation of not automatically creating intermediate keys when needed (for exa...
New
aadeshere1
I have a another noob question about loop. Since elixir is immutable, while loop is not directly possible. total = 10 while total != 0 ...
New
greenz1
I have a phoenix application from which a user can download multiple(5-6) files of size 1MB. I couldn’t find anything related to sending ...
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
SoCreat
i’m a new one to elixir which editor can i use vs code? or atom? Thanks! :smiley:
New

Other popular topics Top

joaquinalcerro
Hi there, I am working with Ecto-Postgresql and I need to call all of the records from a specific table but the table has 40,000 records...
New
JakeBecker
TL;DR: I’ve just released an implementation of Microsoft’s IDE-independent Language Server Protocol for Elixir. It adds language support ...
1144 54921 245
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
joeerl
Hello again - after a longish gap I’ve decided I really must dig into Elixir and see what’s been happening here - so I have a few questio...
New
AstonJ
Seen any cool LiveView demos, sample apps or examples? Please post them here! :003:
New

We're in Beta

About us Mission Statement