# `Macaw.Template.Kit`
[🔗](https://github.com/dcoai/macaw/blob/v0.6.0/lib/macaw/template/kit.ex#L1)

The template kit (spec/12 §2.1): a template and its registered layers checked against
the stacked-result rules (spec/06 §2.6), so an author proves in a test that every page
that may stack them gets a valid page.

    test "the site template and its layers stack" do
      assert Macaw.Template.Kit.check(registry, "site", stacks: [["project_toc", "full_width"]]) == :ok
    end

It stacks the template alone, the template with each registered layer on it alone, and
each stack `stacks:` lists, and each of them again with print. A failure is a value,
never a raise. Adopters add rules as check sets (`Macaw.Template.Kit.Set`), never a kit
of their own.

# `failure`

```elixir
@type failure() :: %{
  stack: [String.t()],
  print: boolean(),
  faults: [Macaw.Base.Fault.t(), ...]
}
```

# `check`

```elixir
@spec check(Macaw.Registry.t(), String.t() | atom()) ::
  :ok | {:error, [failure(), ...]}
```

`check/3` with no options.

# `check`

```elixir
@spec check(Macaw.Registry.t(), String.t() | atom(), keyword()) ::
  :ok | {:error, [failure(), ...]}
```

A template and its layers checked: `:ok`, or `{:error, failures}`, one
`%{stack: names, print: boolean, faults: faults}` per stack that fails, in stacking
order (the template alone, each layer on it in name order, then `stacks:`), each
without print and then with it, its faults `Macaw.Template.stack/3`'s, each naming the
layer at fault.

  * `stacks:`, a list of lists of layer names, the combinations a site uses;
  * `sets:`, check sets (`Macaw.Template.Kit.Set`), each run on every stack that passes.

A template the registry doesn't hold is the one failure of the stack `[template]`. An
option the kit doesn't take is `{[:opts, key], :unknown_key}` and a registry that isn't
one `{[:registry], {:type, :registry}}`, each a failure of no stack (`stack: []`).

---

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