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
Popular in Questions
Other popular topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #elixirconf-us
- #advent-of-code
- #distillery
- #processes
- #forms
- #api
- #metaprogramming
- #hex
- #security









