renderer

package
v0.82.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 25, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const IDMarkdown = "markdown"

Variables

This section is empty.

Functions

This section is empty.

Types

type Option added in v0.82.1

type Option func(*config)

Option configures a TemplateRenderer.

func WithTemplateDir added in v0.82.1

func WithTemplateDir(dir string) Option

WithTemplateDir loads templates from a filesystem directory instead of the embedded defaults. The directory should contain *.tmpl files whose {{define}} names match the default set: proposal, batchOperation, call, parameter, annotations.

func WithTemplateFuncs added in v0.82.1

func WithTemplateFuncs(funcs template.FuncMap) Option

WithTemplateFuncs adds extra template functions to the renderer's func map. These are merged with the built-in functions; caller-provided functions take precedence over built-ins if keys collide.

func WithTemplates added in v0.82.1

func WithTemplates(templates map[string]string) Option

WithTemplates provides in-memory template overrides keyed by any name. Each value must contain a valid {{define "name"}} block -- the key itself is used only as a template set label and does not need to match the define name. Useful for testing or programmatic template generation.

type Registry

type Registry struct {
	// contains filtered or unexported fields
}

Registry manages renderer registration and lookup

func NewRegistry

func NewRegistry() *Registry

NewRegistry creates a new renderer registry

func (*Registry) Get

func (r *Registry) Get(id string) (Renderer, bool)

Get retrieves a renderer by ID

func (*Registry) List

func (r *Registry) List() []string

List returns all registered renderer IDs

func (*Registry) Register

func (r *Registry) Register(renderer Renderer) error

Register adds a renderer to the registry. Returns an error if: - renderer is nil - renderer ID is empty - a renderer with the same ID is already registered

type RenderRequest

type RenderRequest struct {
	Domain          string
	EnvironmentName string
}

RenderRequest encapsulates the domain and environment name

type Renderer

type Renderer interface {
	ID() string
	RenderTo(w io.Writer, req RenderRequest, proposal analyzer.AnalyzedProposal) error
}

Renderer transforms an AnalyzedProposal into a specific output format

type TemplateRenderer added in v0.82.1

type TemplateRenderer struct {
	// contains filtered or unexported fields
}

TemplateRenderer renders an AnalyzedProposal using Go text/template.

func NewMarkdownRenderer added in v0.82.1

func NewMarkdownRenderer(opts ...Option) (*TemplateRenderer, error)

NewMarkdownRenderer creates a TemplateRenderer with embedded markdown templates.

func (*TemplateRenderer) ID added in v0.82.1

func (r *TemplateRenderer) ID() string

func (*TemplateRenderer) RenderTo added in v0.82.1

func (r *TemplateRenderer) RenderTo(w io.Writer, req RenderRequest, proposal analyzer.AnalyzedProposal) error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL