# `PhoenixVapor.Template`
[🔗](https://github.com/elixir-volt/phoenix_vapor/blob/v0.6.1/lib/phoenix_vapor/template.ex#L1)

A Vue template compiled for rendering on the server: static HTML and the
dynamic slots between it, the shape of `%Phoenix.LiveView.Rendered{}`.

A template comes from `Vize.split_template/2`, compiled by PhoenixVapor's
compiler. Its expressions are parsed, and every
slot's `:position` is `{line, column}` in `:file`. Blocks inside it, such as
a `v-if` branch, are templates too.

# `position`

```elixir
@type position() :: {pos_integer(), pos_integer()}
```

# `t`

```elixir
@type t() :: %PhoenixVapor.Template{
  file: Path.t() | nil,
  fingerprint: non_neg_integer() | nil,
  slots: [map()],
  statics: [String.t()]
}
```

# `blocks`

```elixir
@spec blocks(map()) :: [t() | map()]
```

The blocks directly inside a slot. See `map_blocks/3`.

# `exprs`

```elixir
@spec exprs(t()) :: [{term(), map()}]
```

Every expression in a template, in document order. See `map_exprs/3`.

# `fingerprint`

```elixir
@spec fingerprint([String.t()], [map()]) :: non_neg_integer()
```

Identifies statics and slots, as the fingerprint of a
`%Phoenix.LiveView.Rendered{}` does, so LiveView sends statics only when
they change.

# `map_blocks`

```elixir
@spec map_blocks(map(), acc, (block, acc -&gt; {block, acc})) :: {map(), acc}
when acc: term(), block: t() | map()
```

Maps the blocks directly inside a slot, threading an accumulator: a
`v-if`'s branches, a `v-for`'s body, a component's slot content, a
`<slot>`'s fallback, and a fragment's template. Other slots have none.

# `map_exprs`

```elixir
@spec map_exprs(block, acc, (term(), map(), acc -&gt; {term(), acc})) :: {block, acc}
when block: t() | %{slots: [map()]}, acc: term()
```

Maps every expression in a template, threading an accumulator: `fun` gets
the expression, the slot it belongs to, and the accumulator. A component's
own template, under `:component`, belongs to that component and is skipped.

# `new`

```elixir
@spec new([String.t()], [map()], Path.t() | nil) :: t()
```

A template from its statics and compiled slots, with their fingerprint.

# `put_keys`

```elixir
@spec put_keys(block) :: block when block: t() | map()
```

Stores on every slot, in this template and the blocks inside it, the root
assign keys its expressions read, its own and its blocks', as `:keys`.
Rendering skips a slot none of whose keys changed. Call it again after
replacing a template's expressions.

# `slot_exprs`

```elixir
@spec slot_exprs(map()) :: [term()]
```

The expressions in one slot, including the blocks inside it.

---

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