render

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Feb 11, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package render provides two-phase template rendering with validation.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CollectConfig

type CollectConfig struct {
	TemplateDir string
	OutputDir   string
	Data        any
	Config      *config.ParsedConfig // nil = no path transformation
	Engine      *engine.Engine
}

CollectConfig configures the Collect function.

type ExecuteResult

type ExecuteResult struct {
	Skipped map[string]bool // Paths that were skipped due to no-overwrite
}

ExecuteResult contains information about executed outputs.

type Output

type Output struct {
	SourcePath  string      // Relative path in template dir
	OutputPath  string      // Absolute path in output dir
	Content     []byte      // Rendered content (nil for copied files)
	CopyFrom    string      // Source path if copying verbatim (empty if rendered)
	Permissions os.FileMode // File permissions to apply
	Overwrite   bool        // Whether to overwrite existing files (default true)
}

Output represents a single file to be written.

type Plan

type Plan struct {
	Outputs []Output
}

Plan represents the complete rendering operation.

func Collect

func Collect(cfg CollectConfig) (*Plan, error)

Collect walks the template directory and builds a Plan. It collects all outputs into memory for validation before any writes.

func (*Plan) Execute

func (p *Plan) Execute(writer *output.Writer) (*ExecuteResult, error)

Execute writes all files in the Plan. Returns ExecuteResult with information about skipped files.

func (*Plan) OutputCount

func (p *Plan) OutputCount() int

OutputCount returns the number of outputs in the plan.

func (*Plan) Preview

func (p *Plan) Preview() string

Preview returns a human-readable summary of planned outputs.

func (*Plan) Validate

func (p *Plan) Validate() []error

Validate checks the Plan for collisions and security issues. Returns all errors found (doesn't stop at first error).

Jump to

Keyboard shortcuts

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