walker

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: 6 Imported by: 0

Documentation

Overview

Package walker provides directory traversal and template rendering functionality.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Walk

func Walk(cfg Config) error

Walk traverses a template directory, rendering .tmpl files and copying others.

Types

type Config

type Config struct {
	// TemplateDir is the source directory containing templates.
	TemplateDir string

	// OutputDir is the destination directory for rendered output.
	OutputDir string

	// Data is the template data to use for rendering.
	Data any

	// Engine is the template rendering engine.
	Engine *engine.Engine

	// Writer is the output writer.
	Writer *output.Writer

	// TransformPath is an optional callback to transform relative paths.
	// If nil, paths are used as-is.
	// The function receives the relative path and data, and returns the transformed path.
	TransformPath func(relPath string, data any) (string, error)

	// ValidateSymlinks enables symlink security validation.
	// When true, symlinks that resolve outside the template directory cause an error.
	ValidateSymlinks bool

	// OnRendered is called after a template file is rendered.
	// Parameters: source relative path, destination absolute path.
	OnRendered func(srcRel, dstAbs string)

	// OnCopied is called after a non-template file is copied.
	// Parameters: source relative path, destination absolute path.
	OnCopied func(srcRel, dstAbs string)
}

Config holds configuration for directory walking and rendering.

Jump to

Keyboard shortcuts

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