SvelteRender v0.1.0 SvelteRender View Source

Svelte Renderer

Link to this section Summary

Functions

Returns a specification to start this module under a supervisor.

Given the component_path and props, returns html.

Same as get_html/2 but wraps html in a div which is used to hydrate svelte component on client side.

Starts the SvelteRender and workers.

Stops the SvelteRender and underlying node svelte render service

Link to this section Functions

Returns a specification to start this module under a supervisor.

See Supervisor.

Link to this function

get_html(component_path, props \\ %{})

View Source
get_html(binary(), map()) :: {:ok, binary()} | {:error, map()}

Given the component_path and props, returns html.

component_path is the path to your svelte component module relative to the render service.

props is a map of props given to the component. Must be able to turn into json

Link to this function

render(component_path, props \\ %{})

View Source
render(binary(), map()) :: {:safe, binary()}

Same as get_html/2 but wraps html in a div which is used to hydrate svelte component on client side.

This is the preferred function when using with Phoenix

component_path is the path to your svelte component module relative to the render service.

props is a map of props given to the component. Must be able to turn into json

Link to this function

start_link(args)

View Source
start_link(keyword()) :: {:ok, pid()} | {:error, any()}

Starts the SvelteRender and workers.

Options

  • :render_service_path - (required) is the path to the svelte render service relative to your current working directory
  • :pool_size - (optional) the number of workers. Defaults to 4

Stops the SvelteRender and underlying node svelte render service