Documentation
¶
Overview ¶
Package render compiles and evaluates a route's Go-template fields — title, message, and the params/headers values. Templates are parsed once at load (fail-fast) and rendered per request against the webhook payload with the shared funcmap (sprout helpers plus a strict env; no filesystem or network). Missing keys are tolerated (`<no value>`), matching the gate's dyn/missing-key handling.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Data ¶
type Data struct {
Payload any
Headers map[string]string
Query map[string]string
Method string
Route string
Now time.Time
}
Data is the variable environment a field template renders against. The typed fields are projected (by vars) onto lower-cased template variables — .payload, .headers, .query, .method, .route, .now — so a route's templates use the same names as the CEL gate.
type Map ¶
type Map struct {
// contains filtered or unexported fields
}
Map is a compiled set of named value-templates — a route's params or headers. Keys are literal; values are templates.
func CompileMap ¶
CompileMap parses every value in m with no shared snippets.
type Set ¶
type Set struct {
// contains filtered or unexported fields
}
Set is a compiled collection of named template snippets (the top-level `templates:` block). It is shared across a config's routes so any field template can reuse a snippet via {{ template "name" . }} or {{ include "name" . }}; snippets may reference one another. Build it once at load.
func NewSet ¶
NewSet parses the named snippets into a shared template tree and validates their reference graph: every {{ template }} / include reference must resolve to a declared snippet, no snippet may reference a reserved name, and the graph must be acyclic. The graph checks matter because include re-enters via ExecuteTemplate (resetting text/template's depth guard), so a cycle would recurse until the goroutine stack overflows — a runtime-fatal crash recover() cannot catch. Validating here makes that, and a dangling reference, a load-time failure (boot / `chaski validate`) instead of a render-time fault.