Documentation
¶
Overview ¶
Package tmpl provides template rendering utilities for shell commands.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ShellQuote ¶ added in v0.60.0
ShellQuote quotes s as one POSIX shell word: single quotes, with each embedded single quote closed, escaped and re-opened. Templates reach it as shq.
func UntrustedFuncs ¶ added in v0.60.0
UntrustedFuncs returns the helpers that fence outside content (a PR body, a webhook payload) in a prompt:
- untrustedStart renders the opening tag. It takes optional key/value pairs that become attributes: {{ untrustedStart "source" "github" }}.
- untrustedEnd renders the closing tag.
- untrustedNotice renders a sentence telling the agent what the tags mean.
The id is part of the tag name rather than an attribute because a closing tag cannot carry attributes, and a bare closer would be trivial to forge. It is drawn fresh for each call, so call this once per render: content written before the render cannot know the id, and a closing tag it carries cannot close the fence.
Types ¶
type Config ¶
type Config struct {
ScriptPaths map[string]string // "hive-tmux" -> "/path/to/bin/hive-tmux"
AgentCommand string // default profile command (e.g., "claude")
AgentWindow string // default profile key / tmux window name
AgentFlags string // shell-quoted flags string
}
Config holds all template rendering context.
type Renderer ¶
type Renderer struct {
// contains filtered or unexported fields
}
Renderer renders Go templates with shell-oriented helper functions.
func NewValidation ¶
func NewValidation() *Renderer
NewValidation creates a Renderer with safe defaults for template syntax checking. Template functions return placeholder values — output is discarded, only parse errors matter.
func (*Renderer) ValidateSyntax ¶ added in v0.55.0
ValidateSyntax parses tmpl without executing it. Use this instead of Render when the template's data shape includes dynamic map fields (e.g. map[string]any) whose keys can't be known at validation time — executing with missingkey=error would reject valid templates referencing keys that only exist at render time.