render

package
v0.15.0 Latest Latest
Warning

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

Go to latest
Published: Jun 4, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Render

func Render(stdout io.Writer, loader *tmpl.Loader, tmplName string, data any, opts Options) error

func WriteRaw added in v0.14.0

func WriteRaw(stdout io.Writer, body []byte, opts Options) error

WriteRaw applies the standard --out / --stdout / --force / --dry-run / --quiet routing to an already-rendered body. Used by commands that render their content inline (currently: license, whose template bodies are Go constants rather than embedded files).

Types

type ArtifactPayload added in v0.14.0

type ArtifactPayload interface {
	ArtifactPayload() (sections []sections.RenderedSection, ctx any)
}

ArtifactPayload is implemented by cmd-level data structs that join the v1 artifact render path (currently: postmortem). It lets the render pipeline extract the pre-merged section list and the per-template ctx without coupling to cmd-specific types.

type Options

type Options struct {
	Out          string
	Stdout       bool
	Force        bool
	DryRun       bool
	Default      string
	TemplatePath string // optional: read template from this file path instead of the embedded/loader chain
	JSON         bool   // emit the template data as JSON instead of rendering the template
	Quiet        bool   // suppress informational messages (the "wrote <file>" line, dry-run notes)
	// BootstrapJSON controls --json shape for commands that haven't migrated
	// to a sections manifest. When true (the default for legacy commands),
	// the rendered markdown is wrapped in a bootstrap envelope
	// `{meta: <data>, sections: [{id:"body", title:<H1>, type:"text",
	// required:true, body:<rendered markdown>}]}` so every command speaks
	// the same {meta, sections} JSON contract. When false (postmortem), the
	// caller has already shaped `data` as {meta, sections} itself and JSON
	// short-circuits straight to MarshalIndent without rendering markdown.
	BootstrapJSON bool
	// RenderArtifact switches the render path from Go-template execution
	// to the v1 YAML artifact format introduced in v0.14.0. When true,
	// the loader resolves <name>.yaml via LoadArtifactBytes, ParseArtifact
	// builds an Artifact, and sections.RenderArtifact composes the
	// markdown. `data` must implement ArtifactPayload (returning the
	// pre-merged section list and the template ctx).
	RenderArtifact bool
}

Jump to

Keyboard shortcuts

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