Closed dev-guy closed 1 year ago
Can you give a code example, will be easier for me to debug.
This link was broken a few seconds ago, please retry.
It's not happening any more. Is it a requirement that ~V is used with a live view?
I'm trying it out, the way I see it is:
All this being said, it might be interesting to look into how to render Svelte templates directly, this way we avoid the "one line template" like shown here: https://github.com/dev-guy/phoenix-ash-svelte-flowbite/blob/ad7d00fec03a8c2017076fd9283f50af2122102a/lib/kantan_web/controllers/page_html/tiptap.html.heex
Let me know if that makes sense, I might be wrong here btw :)
@woutdp yes, that’s exactly what I’m trying to do for dead views. I’m trying to get rid of the one line file. I thought sigil V would do that. However, I still need a way to disable SSR. I frankly don’t know enough about Phoenix and liveview to know what a component is versus a non-component. Assume I know nothing. If I must use liveview with the sigil, that’s fine. Live views just feel heavy.
Disabling SSR is a good point, I would suggest for now only using ~V inside a LiveView or LiveComponent. For Functional components and dead views, I'd recommend using <LiveSvelte...
syntax.
I think I need some more time to think about how ~V
would interact properly with Functional components as passing options such as disabling SSR is not straightforward I think. It might be possible though. Same with dead views.
So for now I'd recommend using the ~V sigil only in LiveViews and LiveComponents.
As for the difference between components and non-components. You can think of components just like in Svelte, snippets of reusable code. Non components are views, so it would encapsulate the entire page (or in the case of LiveView, can be embedded in a dead view layout)
I'm using ~V for a dead view that doesn't use assigns. The compiler complains that assigns is defined but not used. So I rename it to _assigns. Then I get the error: