Documentation
¶
Overview ¶
Package presets defines the Source interface for per-field YAML presets and provides a filesystem-backed implementation.
Clients can either implement Source directly (e.g. as a thin adapter over an existing preset registry) or pass an fs.FS to FromFS to get a default implementation that loads presets from a YAML tree.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Source ¶
type Source interface {
// ListFields returns the field names that have at least one preset.
ListFields() []string
// ListPresets returns the preset names available for the given field,
// or an empty slice if the field has no presets.
ListPresets(field string) []string
// PresetYAML returns the YAML snippet for (field, name) or an error if
// either is unknown.
PresetYAML(field, name string) (string, error)
}
Source supplies YAML preset snippets keyed by (field, preset name). The editor uses it to populate the preset picker and to seed the YAML editor when a block is opened.
func FromFS ¶
FromFS returns a Source backed by an fs.FS rooted at root (use "." for the whole filesystem).
Layout convention:
<root>/<field>/<preset>.yaml
ListFields enumerates the directories under root; ListPresets enumerates the .yaml files within each field directory (stripping the extension).
FromFS is convenient for clients that ship presets as a Go embed.FS.