Frontmatter
Every template starts with a YAML mapping between two --- lines. It names the template and the sender profile it goes out under, and carries the envelope text: the subject, the inbox preview line and, for some profiles, the sender. A kit can add keys of its own, such as a footer note.
---
template: job.offered
profile: driver
subject: "New job: {{pickup_area}} to {{dropoff_area}} · {{fee}}"
preheader: "Accept by {{accept_by}}. {{distance}}, one produce box."
note: If another courier accepts first, the link will say so.
---
The first five keys belong to the engine and mean the same in every kit. note is a key of the Quiet kit, which shows it in its footer.
Look up a core key
| Key | Type | Required | Notes |
|---|---|---|---|
template | string | yes | Must equal the name passed to Compile. |
profile | string | yes | The name of a Profile in the renderer's Config. Checked by Render. |
subject | text | yes | Merge tags allowed. At render, a subject that is empty or contains CR, LF or NUL is an error. |
preheader | text | recommended | The inbox preview line. Leaving it out is the warning frontmatter: no preheader. A tag with no value renders as nothing here rather than failing. |
from | text | profile-dependent | Required, and only allowed, when the profile has no fixed From. |
"Text" is a YAML string that may hold merge tags. A key of the wrong YAML type is an error at the key, such as frontmatter: "subject" must be a string. A key that is neither a core key nor one the kit declares is frontmatter: unknown key "colour".
1:1, because there is no key to point at: frontmatter: missing "profile". Every other frontmatter error points at the key's own line and column. A merge-tag error in a one-line subject, preheader or from points at the tag itself; in a multi-line YAML string it points at the key.Match the name
template exists so the file and the Go code can't drift apart. Compile the file under another name and the compile fails:
payout.sent:2:1: frontmatter: template "payout" does not match name "payout.sent"
Name a profile
Profiles belong to the Renderer, not to the kit, so Compile only checks that profile is a string. Render looks it up and reports a name it doesn't know at the key, with the template's position:
auth.reset:3:1: unknown profile "nope"
Message.Profile carries the name, so your application can route on it. Profiles are described in Profiles and config.
Set the sender
A profile either has a fixed From or leaves the sender to the template. The template's from must match that choice:
| Profile | from in the template | Error when broken |
|---|---|---|
Fixed From | Not allowed. | frontmatter: "from" is not allowed: profile "security" has a fixed From |
No From | Required. | frontmatter: profile "open" has no From, so "from" is required |
FromDomain set | Must be on that domain. | from "kim@other.example" is not on example.com |
A literal from is parsed as an address when the template compiles: frontmatter: "from" is not a valid address: mail: no angle-addr. A from with merge tags is parsed at render. Every rule that needs the profile runs at render, reported at the from or profile key.
Use the kit's keys
A kit declares extra keys under frontmatter: in its kit.yaml. They are typed like component attributes and follow the same rules: required, required_with, default and, for an enum, values. Plain declares none. Quiet declares seven, which its layout reads for the masthead and the footer:
| Key | Type | Default |
|---|---|---|
issue | text | — |
legal | flag | false |
note | inline | — |
about | text | — |
reason | inline | — |
optout | inline | — |
nav | flag | true |
What each one shows is in The Quiet kit. In a template, a kit key is written like any other:
---
template: order.out_for_delivery
profile: buyer
subject: Your produce box is on its way
preheader: "Arriving at {{destination}} by {{eta}} today."
note: "Questions? [Get help](https://loam.example/help). Payment is held until you confirm delivery."
---
Each type takes a different YAML value:
| Type | YAML value | Error when wrong |
|---|---|---|
text, url | A string. Merge tags allowed. | frontmatter: "about" must be a string |
inline | A string of exactly one paragraph of inline Markdown. Merge tags allowed. | frontmatter: "note" must be one paragraph |
int | A YAML integer. | frontmatter: "seats" must be an integer |
flag | true or false. | frontmatter: "legal" must be a boolean |
enum | One of the values, literally. | frontmatter: "tier" must be one of free, pro |
list | A YAML list of strings, or one comma-separated string. | frontmatter: "topics" must be a list of strings |
A required key that is missing is frontmatter: missing "campaign", at 1:1. A key with required_with is reported at the other key: frontmatter: "banner_alt" is required when "banner" is set. An inline value takes no strikethrough, link titles or images (frontmatter: strikethrough is not allowed).
A key the template leaves out takes its default. With no default it is "" for text, url and enum, an empty list, or no value for inline (D49), so a kit template can test it with if. Kit templates read the keys as .Doc.Front; see Templates and views.
seats, tier, topics, campaign and banner messages above come from a scratch kit made with lttr kit init and given those keys; the shipped kits have no enum, int or list keys. How to declare keys is in kit.yaml.Next steps
- Components for the body of the template.
- Profiles and config for the profiles
profileandfromare checked against.