# `PhoenixKitOG.Templates`
[🔗](https://github.com/BeamLabEU/phoenix_kit_og/blob/0.4.0/lib/phoenix_kit_og/templates.ex#L1)

Context for managing OpenGraph templates. CRUD only — the editor and
renderer live elsewhere.

Mutating functions accept an `opts` keyword list; pass `actor_uuid:
user_uuid` to attribute the change in the activity feed. Omitting it
logs an anonymous entry — still auditable, just not attributed.

# `change`

```elixir
@spec change(PhoenixKitOG.Schemas.Template.t(), map()) :: Ecto.Changeset.t()
```

# `create`

```elixir
@spec create(map(), keyword()) ::
  {:ok, PhoenixKitOG.Schemas.Template.t()} | {:error, Ecto.Changeset.t()}
```

# `delete`

```elixir
@spec delete(PhoenixKitOG.Schemas.Template.t(), keyword()) ::
  {:ok, PhoenixKitOG.Schemas.Template.t()}
  | {:error, Ecto.Changeset.t() | :not_found}
```

Deletes a template. The foreign key cascades to every assignment that
uses it, so each of those leaves its own `assignment.deleted` row
(metadata `"cascade" => "template.deleted"`), written in the same
transaction as the delete: the audit trail names exactly the assignments
that went with it, or nothing at all when the delete rolls back.

# `get`

```elixir
@spec get(binary()) :: PhoenixKitOG.Schemas.Template.t() | nil
```

Returns `nil` when no template matches.

# `list`

```elixir
@spec list() :: [PhoenixKitOG.Schemas.Template.t()]
```

Returns all templates, ordered by name.

# `update`

```elixir
@spec update(PhoenixKitOG.Schemas.Template.t(), map(), keyword()) ::
  {:ok, PhoenixKitOG.Schemas.Template.t()} | {:error, Ecto.Changeset.t()}
```

---

*Consult [api-reference.md](api-reference.md) for complete listing*
