Documentation
¶
Overview ¶
Package templates provides embedded templates for spec types.
Index ¶
- func Available() []types.SpecType
- func HasTemplate(specType types.SpecType) bool
- func NewFileLoader(dir string) *fileLoader
- func RenderForProject(specType types.SpecType, projectName string) (string, error)
- type Loader
- func DefaultLoader() Loader
- func EmbeddedLoader() Loader
- func LoaderForWorkflow(w *sws.LoadedWorkflow) Loader
- func NewChainLoader(loaders ...Loader) Loader
- func NewEmbedFSLoader(fsys embed.FS, dir string) Loader
- func NewMapLoader(templates map[string]*spectemplate.Template) Loader
- func NewSubFSLoader(fsys fs.FS) Loader
- type RenderOptions
- type Template
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 LoaderForWorkflow ¶ added in v0.15.0
func LoaderForWorkflow(w *sws.LoadedWorkflow) Loader
LoaderForWorkflow returns a template loader for a loaded workflow. The workflow's own templates take priority (falling back to the default embedded templates when the workflow has none), with prism-roadmap's canonical canvas templates chained last.
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 NewMapLoader ¶ added in v0.15.0
func NewMapLoader(templates map[string]*spectemplate.Template) Loader
NewMapLoader creates a loader backed by a map of spec type to template, as provided by specification-workflow-spec's LoadedWorkflow.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.