# Template context

A pack template reads **context**: named facts about the subject it renders (a schema, an operation, a feature), plus metadata such as the file being written and the pack's inputs. Every path is lower `snake_case`, for example `schema.fields[].name.camel`.

## Only what a template asks for

Before rendering, the template server analyses the template and reports the exact paths it reads. The engine checks them against the context vocabulary and projects only those paths. A large vocabulary therefore never means a large object per file, and a typo in a path fails before anything renders.

## Raw and derived context

Raw context mirrors the canonical meaning: values, constraints, relations, HTTP bindings. Derived context saves templates from rebuilding common facts:

| Need                        | Read                                                    | Instead of                                       |
| --------------------------- | ------------------------------------------------------- | ------------------------------------------------ |
| What kind of value is this? | `field.value.is.uuid`, `field.value.is.schema`          | comparing `kind`, `type` and `format` strings    |
| Is a bound declared?        | `length.has_min`, `range.has_max`                       | `min is not none` (and truthiness bugs with `0`) |
| A safe literal              | `field.default.value_json`, `pattern.match_json[]`      | encoding values in the template                  |
| One kind of HTTP binding    | `facets.http.input_groups.body[]`                       | filtering `inputs`                               |
| Path pieces                 | `facets.http.path.segments[]` (`literal` / `parameter`) | parsing `/users/{id}`                            |
| The DTO for this value      | `field.value.generated.schema_validation.symbol`        | searching `file.dependencies`                    |

Derived facts never name a framework: turning `is.uuid` into `z.string().uuid()` or `@IsUUID()` stays in your pack, where you can see and change it.

## Renderers

Jinja, Handlebars and Liquid read the same paths. Jinja suits packs with macros and local logic; Handlebars suits templates that mostly look like their output, since derived context removes most of the branching. Mustache renders, but can't be analysed, so it isn't used for planned generation.

## Discover the vocabulary

```bash
dryv context list
dryv context show "schema.fields[].value.is.boolean"
dryv context show "schema.fields[].value.generated.schema_validation" --json
```

`show` prints where a path starts, whether it is one value, optional or a list, and where it comes from (canonical meaning, a derived fact, or the generation plan). An invalid path explains why.
