Assign helpers that work in both halves of a Dstar page module.
use Dstar.Page imports these instead of Phoenix.Component's assign
family, so one set of names works everywhere:
- On a
%Plug.Conn{}(inmount/2,handle_event/3,handle_connect/2,handle_info/2) they behave likePlug.Conn.assign/3. - On anything else (sockets, assigns maps inside function components)
they delegate to
Phoenix.Component.
Summary
Functions
Assigns one key/value or many key/values.
conn |> assign(:count, 1)
conn |> assign(count: 1, name: "rico")Keys must be atoms when assigning to a %Plug.Conn{}, matching Plug.Conn.assign/3 semantics.
Assigns a value computed by fun only when key is absent.
fun may take zero arguments or the current assigns.
Updates an existing assign with fun. Raises KeyError if absent.