Documentation
¶
Overview ¶
Package templates provides embedded templates for spec types.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func HasTemplate ¶
HasTemplate returns true if a template exists for the spec type.
func NewFileLoader ¶
func NewFileLoader(dir string) *fileLoader
NewFileLoader creates a loader that reads templates from a directory. Templates are named: {spec-type}.md (e.g., prd.md, security.md)
Types ¶
type Loader ¶
type Loader interface {
// Load returns the template for a spec type.
Load(specType types.SpecType) (*Template, error)
// Available returns all available spec types.
Available() []types.SpecType
}
Loader loads templates from various sources.
func DefaultLoader ¶
func DefaultLoader() Loader
DefaultLoader returns the default template loader (embedded templates).
func EmbeddedLoader ¶
func EmbeddedLoader() Loader
EmbeddedLoader returns a loader that uses embedded templates.
func NewChainLoader ¶
NewChainLoader creates a loader that tries multiple loaders in order. The first loader that can load a template wins.
func NewEmbedFSLoader ¶
NewEmbedFSLoader creates a loader that reads templates from an embedded filesystem. This is useful for organizations that want to compile custom templates into their CLI.
Usage:
//go:embed templates/*.md var orgTemplates embed.FS loader := templates.NewEmbedFSLoader(orgTemplates, "templates")
func NewSubFSLoader ¶
NewSubFSLoader creates a loader from an fs.FS interface. This is useful when working with fs.Sub() results.
type RenderOptions ¶
RenderOptions contains options for rendering a template.
func DefaultRenderOptions ¶
func DefaultRenderOptions() RenderOptions
DefaultRenderOptions returns default options for rendering.
type Template ¶
Template represents a loaded template with metadata.
func LoadWithLoader ¶
LoadWithLoader loads a template using a specific loader.
func (*Template) Render ¶
func (t *Template) Render(opts RenderOptions) string
Render renders the template with the given options.