PhiaUiDesign.Templates.PageTemplates (phia_ui v0.1.17)

Copy Markdown View Source

Pre-built page scaffolds for the PhiaUI Design editor.

Each template function builds a set of nodes in a Scene, creating a ready-to-customize page layout with real PhiaUI components.

Templates return {:ok, scene} on success, or {:error, reason} on failure. Node IDs are generated automatically so templates can be applied multiple times to different scenes without collision.

Usage

scene = Scene.new()
{:ok, scene} = PageTemplates.apply_template(scene, :dashboard)

Available templates

PageTemplates.list()
# => [%{key: :dashboard, name: "Dashboard", ...}, ...]

Summary

Functions

Apply a page template to a scene.

Get a single template's metadata by key.

Return the list of valid template keys.

List all available page templates with metadata.

List templates filtered by category.

Functions

apply_template(scene, template_key)

@spec apply_template(PhiaUiDesign.Canvas.Scene.scene_id(), atom()) ::
  {:ok, PhiaUiDesign.Canvas.Scene.scene_id()} | {:error, atom()}

Apply a page template to a scene.

Inserts the template's nodes into the given scene and returns {:ok, scene}. The scene is mutated in place (ETS), so the returned reference is the same as the input.

Returns {:error, :unknown_template} if the key is not recognized.

get(key)

@spec get(atom()) :: map() | nil

Get a single template's metadata by key.

keys()

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

Return the list of valid template keys.

list()

@spec list() :: [map()]

List all available page templates with metadata.

Returns a list of maps with :key, :name, :description, and :category.

list_by_category(category)

@spec list_by_category(atom()) :: [map()]

List templates filtered by category.

Categories: :app, :auth, :marketing, :utility.