Heex and Alpine

How to put dynamic elixir code in a heex template for alpinejs? For example -

x-data="{username: {@current_user.username}}"

The above is not getting interpreted correctly. In heex template what is the correct expression for this?

x-data={"username: '#{@current_user.username}'"}
1 Like

i think it should be more like:

x-data={"{username: '#{@current_user.username}'}"}

2 Likes