Document template partials
This commit is contained in:
@@ -13,6 +13,12 @@ Templates are Go `text/template` files. The current implemented templates are:
|
||||
- `internal/reporttemplate/templates/tomorrow.md.tmpl`
|
||||
- `internal/reporttemplate/templates/hourly.md.tmpl`
|
||||
|
||||
Shared named partials live under `internal/reporttemplate/templates/partials/`:
|
||||
|
||||
- `daypart_forecast.md.tmpl`, used by Daily and Tomorrow
|
||||
- `today_daypart_forecast.md.tmpl`, used by Today
|
||||
- `precipitation_timing.md.tmpl`, used by Daily, Today, and Tomorrow
|
||||
|
||||
Templates are rendered from structured contexts such as `DailyRenderContext`,
|
||||
`TodayRenderContext`, `TomorrowRenderContext`, and `HourlyRenderContext`.
|
||||
Weather data collection, derivation, module execution, generated text
|
||||
@@ -27,6 +33,9 @@ validation, and artifact paths are handled before template rendering.
|
||||
templates.
|
||||
- Missing template keys are errors. A misspelled variable will fail rendering.
|
||||
- No custom template functions are currently registered.
|
||||
- Named partials are invoked with `{{ template "name" . }}`. Pass the current
|
||||
render context (`.`) unless the partial is intentionally designed for a
|
||||
narrower value.
|
||||
- Optional module stanzas are pointers and should be guarded with
|
||||
`{{ with .Modules.WeatherStory }}...{{ end }}`.
|
||||
- Slices can be rendered with `{{ range .Items }}...{{ else }}...{{ end }}`.
|
||||
@@ -131,6 +140,8 @@ Daily generated text uses `.GeneratedText.Summary`,
|
||||
`.GeneratedText.Confidence`. Forecast discussion is a slice of paragraphs and
|
||||
should be rendered with `range`.
|
||||
|
||||
Daily uses the shared `daypart_forecast` and `precipitation_timing` partials.
|
||||
|
||||
Daily uses template ID `daily`, generated-text schema ID `daily`, and prompt
|
||||
source `internal/reporttemplate/prompts/daily.generated_text.md`.
|
||||
|
||||
@@ -162,6 +173,10 @@ Today generated text uses `.GeneratedText.Summary`,
|
||||
`.GeneratedText.Confidence`. Forecast discussion is a slice of paragraphs and
|
||||
should be rendered with `range`.
|
||||
|
||||
Today uses the `today_daypart_forecast` partial so elapsed or missing dayparts
|
||||
can be omitted while Daily and Tomorrow keep their fallback row. It also uses
|
||||
the shared `precipitation_timing` partial.
|
||||
|
||||
Today uses template ID `today`, generated-text schema ID `today`, and prompt
|
||||
source `internal/reporttemplate/prompts/today.generated_text.md`.
|
||||
|
||||
@@ -282,6 +297,10 @@ Daily, Today, and Tomorrow templates should use `.Modules.Dayparts` for
|
||||
ordered daypart rendering. Each item has `Key` and `Summary`; `Summary` is a
|
||||
rich `briefing.DerivedDaypartSummaryModule`.
|
||||
|
||||
The shared daypart partials render from these same `.Modules.Dayparts` values.
|
||||
Edit `daypart_forecast.md.tmpl` for common Daily/Tomorrow wording, and edit
|
||||
`today_daypart_forecast.md.tmpl` for Today-specific omission behavior.
|
||||
|
||||
Common rich daypart fields:
|
||||
|
||||
| Variable | Type | Description |
|
||||
|
||||
Reference in New Issue
Block a user