PhoenixDatastar.Helpers (PhoenixDatastar v0.1.8)

Copy Markdown View Source

Shared helper functions for PhoenixDatastar modules.

Summary

Functions

Extracts the session map from a Plug.Conn.

Extracts the view module name (last part of module path).

Internal assigns that should be filtered from signals.

Renders a view's template.

Filters internal assigns from a map, returning only user-defined signals.

Functions

get_session_map(conn)

@spec get_session_map(Plug.Conn.t()) :: map()

Extracts the session map from a Plug.Conn.

Returns the session data if available, otherwise an empty map.

get_view_name(view)

@spec get_view_name(module()) :: String.t()

Extracts the view module name (last part of module path).

Examples

iex> PhoenixDatastar.Helpers.get_view_name(MyApp.CounterStar)
"CounterStar"

internal_assigns()

@spec internal_assigns() :: [atom()]

Internal assigns that should be filtered from signals.

render_html(view, socket)

@spec render_html(module(), PhoenixDatastar.Socket.t()) :: Phoenix.HTML.Safe.t()

Renders a view's template.

user_signals(assigns)

@spec user_signals(map()) :: map()

Filters internal assigns from a map, returning only user-defined signals.