Astral.Islands.Props (Astral v0.1.6)

Copy Markdown View Source

Normalizes and encodes island props with validation errors tailored for Astral islands.

Props cross from server-rendered HTML into browser JavaScript, so they must be JSON-shaped data or structs that explicitly define how they encode. Plain maps, lists, strings, numbers, booleans, nil, and atoms are accepted. Structs are accepted when they use JSONCodec or implement Jason.Encoder.

Summary

Functions

Returns a JSON string for island props or raises with a helpful error.

Returns JSON-shaped props or raises with a helpful error.

Types

path()

@type path() :: [atom() | String.t() | non_neg_integer()]

Functions

encode!(props, context \\ [])

@spec encode!(
  term(),
  keyword()
) :: String.t()

Returns a JSON string for island props or raises with a helpful error.

normalize!(props, context \\ [])

@spec normalize!(
  term(),
  keyword()
) :: term()

Returns JSON-shaped props or raises with a helpful error.