Caravela.Gen.LiveView (Caravela v0.11.0)

Copy Markdown View Source

Generates Phoenix LiveView modules that mount Svelte components via LiveSvelte.

Output per entity (:books):

  • index.ex — list + delete + navigate-to-edit
  • show.ex — single-record view
  • form.ex — create + edit, with validate round-trips

Every LiveView delegates to the context module generated by Caravela.Gen.Context, so authorization, hooks, and (when enabled) tenant scoping apply automatically. The frontend (the Svelte component) receives props reflecting the socket assigns and sends events back via LiveSvelte's pushEvent.

Returns a list of {path, source} tuples. Files preserve content below the # --- CUSTOM --- marker on regeneration.

Summary

Functions

Render every LiveView for every entity.

Render a single LiveView. kind is :index, :show, or :form.

Render the *_domain.ex companion module for an entity.

Functions

render_all(domain, opts \\ [])

Render every LiveView for every entity.

Options:

  • :root — project root for reading existing files (CUSTOM merge)
  • :with_domain — when true, also emit a Caravela.Live.Domain module per entity and render the form LiveView from the Template-backed variant. Index and show stay plain regardless.

render_entity(domain, entity, kind, opts \\ [])

Render a single LiveView. kind is :index, :show, or :form.

render_form_domain(domain, entity, opts \\ [])

Render the *_domain.ex companion module for an entity.