PhoenixKit.LayoutConfig (phoenix_kit v1.7.27)
View SourceConfiguration manager for PhoenixKit layout integration.
This module provides functions to retrieve and validate layout configuration from the application environment, with fallback to default PhoenixKit layouts.
Configuration
Configure layouts in your application config:
# Minimal configuration - only app layout
config :phoenix_kit, layout: {MyAppWeb.Layouts, :app}
# Full configuration - both root and app layouts
config :phoenix_kit,
root_layout: {MyAppWeb.Layouts, :root},
layout: {MyAppWeb.Layouts, :app}
# With additional options
config :phoenix_kit,
layout: {MyAppWeb.Layouts, :app},
page_title_prefix: "Auth"Usage
iex> PhoenixKit.LayoutConfig.get_layout()
{PhoenixKitWeb.Layouts, :app}
iex> PhoenixKit.LayoutConfig.get_root_layout()
{PhoenixKitWeb.Layouts, :root}
Summary
Functions
Checks if a custom layout is configured (not using default PhoenixKit layouts).
Gets all layout configuration as a map for debugging purposes.
Gets the configured app layout module and template.
Gets the configured page title prefix for authentication pages.
Gets the configured root layout module and template.
Functions
@spec custom_layout?() :: boolean()
Checks if a custom layout is configured (not using default PhoenixKit layouts).
Examples
iex> Application.put_env(:phoenix_kit, :layout, {MyApp.Layouts, :app})
iex> PhoenixKit.LayoutConfig.custom_layout?()
true
iex> Application.delete_env(:phoenix_kit, :layout)
iex> PhoenixKit.LayoutConfig.custom_layout?()
false
@spec get_config() :: map()
Gets all layout configuration as a map for debugging purposes.
Examples
iex> PhoenixKit.LayoutConfig.get_config()
%{
layout: {PhoenixKitWeb.Layouts, :app},
root_layout: {PhoenixKitWeb.Layouts, :root},
page_title_prefix: nil,
custom_layout?: false
}
Gets the configured app layout module and template.
Returns the configured layout tuple or falls back to default PhoenixKit layout.
Examples
iex> Application.put_env(:phoenix_kit, :layout, {MyApp.Layouts, :app})
iex> PhoenixKit.LayoutConfig.get_layout()
{MyApp.Layouts, :app}
iex> Application.delete_env(:phoenix_kit, :layout)
iex> PhoenixKit.LayoutConfig.get_layout()
{PhoenixKitWeb.Layouts, :app}
@spec get_page_title_prefix() :: String.t() | nil
Gets the configured page title prefix for authentication pages.
Examples
iex> Application.put_env(:phoenix_kit, :page_title_prefix, "Auth")
iex> PhoenixKit.LayoutConfig.get_page_title_prefix()
"Auth"
iex> Application.delete_env(:phoenix_kit, :page_title_prefix)
iex> PhoenixKit.LayoutConfig.get_page_title_prefix()
nil
Gets the configured root layout module and template.
Returns the configured root layout tuple or falls back to default PhoenixKit root layout. Root layout is optional and defaults to app layout if not specified.
Examples
iex> Application.put_env(:phoenix_kit, :root_layout, {MyApp.Layouts, :root})
iex> PhoenixKit.LayoutConfig.get_root_layout()
{MyApp.Layouts, :root}
iex> Application.delete_env(:phoenix_kit, :root_layout)
iex> PhoenixKit.LayoutConfig.get_root_layout()
{PhoenixKitWeb.Layouts, :root}