Registry + resolver for module-exposed variables that templates can bind their slots to.
Sources
Global — always available regardless of consumer module. Owned by this module (see
global/0). Includes site host, site URL, site name, current page URL, current locale.Module-declared — external PhoenixKit modules opt in by implementing two optional callbacks:
def og_variables, do: [ %{name: "post_title", type: :text, label: "Post title", description: "..."}, %{name: "post_featured_image", type: :image, label: "Featured image"} ] def og_resolve(var_name, context) # context = %{module_key: "publishing", resource: post_map, conn: conn, language: "en"}og_variables/0declares the shape;og_resolve/2fetches the value at render time. Both are auto-discovered viaPhoenixKit.ModuleDiscovery.
Globals + module-declared variables are combined at assignment-time in the "wire slots" dropdown — the user sees one list per slot, scoped by matching type.
Summary
Functions
Merged list — globals + everything a consumer module declares.
Flat map of all [[global]] values, ready to merge into the
substitution map. Prefers conn fields (real request context); if
no conn is available, falls back to the Phoenix endpoint module
(passed as :endpoint) so the editor can preview real values
without a request.
Given the slots a template uses, an assignment's slot_mapping
(%{slot_name => variable_name}), and a resolution context,
produces the substitution values map for the renderer.
Types
Functions
Merged list — globals + everything a consumer module declares.
@spec global() :: [variable()]
Flat map of all [[global]] values, ready to merge into the
substitution map. Prefers conn fields (real request context); if
no conn is available, falls back to the Phoenix endpoint module
(passed as :endpoint) so the editor can preview real values
without a request.
@spec resolve([PhoenixKitOG.Slots.t()], %{required(String.t()) => String.t()}, map()) :: %{ required(String.t()) => String.t() }
Given the slots a template uses, an assignment's slot_mapping
(%{slot_name => variable_name}), and a resolution context,
produces the substitution values map for the renderer.
Missing wires (slot not in slot_mapping) or unknown variable names
return nil for that slot — the renderer leaves {{slot}} visible,
matching the workspace convention.