Documentation
¶
Overview ¶
Package fieldinterp provides {field} placeholder interpolation with CUE path resolution for nested front-matter access.
Placeholders use the syntax {fieldname}. Nested access uses dot notation ({a.b.c}) and non-identifier keys use CUE quoting ({"my-key".sub}). A literal { is written as {{, and a literal } is written as }}. Missing keys resolve to empty string.
Index ¶
- func ContainsField(text string) bool
- func DiagnoseYAMLQuoting(paramName string, val any) string
- func Fields(text string) []string
- func Interpolate(text string, data map[string]any) string
- func ParseCUEPath(expr string) []string
- func ResolvePath(data map[string]any, path []string) (string, error)
- func SplitOnFields(text string) []string
- func Stringify(v any) string
- func Validate(text string) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ContainsField ¶
ContainsField reports whether text contains at least one {field} placeholder (not counting escaped {{ braces).
func DiagnoseYAMLQuoting ¶
DiagnoseYAMLQuoting checks whether a raw YAML value that was expected to be a string was instead parsed as a map because YAML interpreted {field} placeholder syntax as a flow mapping. Returns a diagnostic message if the conflict is detected, empty string otherwise.
func Fields ¶
Fields returns the field names referenced by {field} placeholders in text. Escaped braces {{ are ignored. For nested paths like {a.b}, returns "a.b".
func Interpolate ¶
Interpolate replaces {field} placeholders in text with values resolved from data using CUE path semantics. Supports nested access ({a.b}) and quoted keys ({"my-key"}). Missing keys resolve to empty string.
func ParseCUEPath ¶
ParseCUEPath parses a CUE path expression into unquoted label segments using cue.ParsePath. Non-identifier keys (hyphens, dots, spaces) must be quoted: "my-key". Returns nil for malformed expressions.
func ResolvePath ¶
ResolvePath walks data using the given path segments and returns the string value at the resolved location.
func SplitOnFields ¶
SplitOnFields splits text on {field} placeholders and returns the literal parts between them. Escaped braces are treated as literals. For "{id}: {name}" it returns ["", ": ", ""].
Types ¶
This section is empty.