# `StarView.Template.Program`
[🔗](https://github.com/Neophen/star_view/blob/v0.7.0/lib/star_view/template/program.ex#L1)

A compiled `~STAR` rendering program. Compiler output; not a construction API.

`run` is a capture-free function generated by the `~STAR` compiler from one
template skeleton. `values` holds the already-evaluated expressions of one
snapshot. The function owns every static byte and the template structure:

  * `run.(:render, values)` returns HTML iodata.
  * `run.(:nodes, values)` returns the equivalent `StarView.Template.Node`
    list, which may contain nested programs.
  * `run.(:key, values)` returns the item key for keyed collections, or `nil`.
  * Any other mode or a malformed `values` tuple raises `ArgumentError`.

Rendering and materializing never evaluate template expressions again; they
only read `values`. `values` is ordinary data and may be replaced or mutated,
so the generated code escapes and validates it on every call exactly like a
hand-built tree. There is no cached HTML, static data or tree in the struct.

`run` is executable code and is trusted like a `Phoenix.HTML.Safe`
implementation: whoever supplies it chooses the markup. Programs are
ordinary server-side values. They are not meant to be serialized or accepted
from untrusted transports.

In modules, the compiler emits hidden named functions and stores external
captures. Snapshots do not pin old module code. An unchanged program works
after recompilation; a removed program raises `StarView.Template.StaleProgramError`.
Diffing treats this as `:template_changed`, including nested programs.

Moduleless evaluation and templates expanded after the compiler hook use
local functions instead. Those values have the ordinary code-lifetime limits
of local functions. They are intended for immediate evaluation.

# `t`

```elixir
@type t() :: %StarView.Template.Program{
  run: (atom(), tuple() -&gt; term()),
  values: tuple()
}
```

# `nodes`

```elixir
@spec nodes(t()) :: [StarView.Template.Node.t()]
```

Returns the program's nodes with nested programs and templates expanded.
