Vue templates as native LiveView rendered structs.
Usage
Sigil — Vue syntax in any LiveView
use PhoenixVapor
def render(assigns) do
~VUE"""
<div>{{ count }}</div>
"""
endSFC — .vue file as a LiveView
use PhoenixVapor, file: "Contacts.vue"The compiler reads the .vue file and auto-detects the mode:
- No
<script setup>— pure server template, zero client JS <script setup>with onlydefineProps— pure server, zero client JS<script setup>withref()— hybrid mode, Vue 3 on the clientruntime: :full— full Vue runtime in QuickBEAM (for component libraries)
Single-file Elixir
Embed Elixir code in the .vue file with <script lang="elixir">:
<script lang="elixir">
def mount(_params, _session, socket) do
{:ok, assign(socket, items: Repo.all(Item))}
end
</script>
<script setup>
const props = defineProps(["items"])
const search = ref("")
</script>
<template>
<input v-model="search" />
<div v-for="item in filtered">{{ item.name }}</div>
</template>Programmatic
PhoenixVapor.render("<div>{{ msg }}</div>", %{msg: "Hello"})
Summary
Functions
Render a Vue template as a %Phoenix.LiveView.Rendered{} struct.
Functions
@spec render(String.t() | map(), map()) :: Phoenix.LiveView.Rendered.t()
Render a Vue template as a %Phoenix.LiveView.Rendered{} struct.