coen.bakker
Daydreaming about Svelte-like syntax inside render functions
I appreciate being able to use AlpineJS inside my render functions, but often I catch myself wishing I could use Svelte syntax instead. And have the compiler turn the Svelte code to plain JS.
What do you think: how messy would that implementation get?
For example:
defmodule AppWeb.PageLive
use Surface.LiveView
def render(assigns) do
~F"""
<div id="page">
{#if @value and count == 0}
<SurfaceComponent id="surface-component"/>
{#else}
<AnotherSurfaceComponent id="another-surface-component"/>
{/if}
<button on:click={handleClick}>
Clicked {count} {count === 1 ? 'time' : 'times'}
</button>
</div>
<script>
let count = 0
function handleClick() {
count += 1
}
</script>
"""
end
end
I am well aware that there are syntax conflicts right from the get-go between Svelte/JavaScript and Elixir/Phoenix/Surface. I reckon the best way of integrating Svelte is… not doing so. But rather extending Surface functionality into the JavaScript domain, or building a compiler layer on top of Phoenix from scratch – and being ‘inspired’ by Svelte.
Would it be a relieve to have such a tool… or not?
First Post!
cmo
{#if @value and count == 0}
How does the server rendered page get the count value from the front-end?
Most Liked
LostKobrakai
What I considered, but never managed to try, with svelte would be using svelte client side only and use a custom svelte store to communicate to the backend, which today could possibly even be something like live_json, though plain channels might work as well.
Last Post!
coen.bakker
Interesting. Have an idea what it might be, but what do you have in mind? In general terms how would you utilize WA?
Popular in Discussions
Other popular topics
Latest Phoenix Threads
Chat & Discussions>Discussions
Latest on Elixir Forum
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
- #api
- #forms
- #metaprogramming
- #security
- #hex









