template

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Aug 3, 2025 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Context

type Context struct {
	Agent string
}

Context holds the context information for template processing, including information about which agent is being used for output.

type Engine

type Engine struct {
	// FileResolver resolves file paths
	FileResolver FileResolver

	// References stores reference content to be appended at the end
	References map[string]string

	// OriginalPaths maps absolute paths to their original relative paths
	OriginalPaths map[string]string

	// AgentType determines the output format
	AgentType string

	// AgentRegistry provides access to registered agents
	AgentRegistry *agent.Registry
	// contains filtered or unexported fields
}

Engine represents the template engine wrapper

func NewEngine

func NewEngine(fileResolver FileResolver, agentType, absTemplateBaseDir string, agentRegistry *agent.Registry) *Engine

NewEngine creates a new template engine

func (*Engine) Agent

func (e *Engine) Agent() string

Agent returns the current agent type being used for template processing.

func (*Engine) Execute

func (e *Engine) Execute(absFilePath string, content string, data any) (string, error)

Execute processes a template with the given data while managing CurrentFilePath

func (*Engine) ExecuteFile

func (e *Engine) ExecuteFile(absFilePath string, data any) (string, error)

ExecuteFile processes a template file with the given data

func (*Engine) FileFunc

func (e *Engine) FileFunc() any

FileFunc generates a file reference helper function

func (*Engine) IncludeFunc

func (e *Engine) IncludeFunc(processTemplate bool) any

IncludeFunc generates an include helper function with optional template processing that accepts multiple paths and combines their content with double newlines as separators

func (*Engine) MCPFunc

func (e *Engine) MCPFunc() any

MCPFunc generates an MCP command helper function

func (*Engine) ReferenceFunc

func (e *Engine) ReferenceFunc(processTemplate bool) any

ReferenceFunc generates a reference helper function with optional template processing that accepts multiple paths and combines their reference markers with commas as separators

func (*Engine) RegisterHelperFunctions

func (e *Engine) RegisterHelperFunctions(t *template.Template) *template.Template

RegisterHelperFunctions registers all template helper functions

type FileResolver

type FileResolver interface {
	// Read reads a file at the given path
	Read(path string) ([]byte, error)

	// Exists checks if a file exists
	Exists(path string) bool

	// ResolvePath resolves a relative path to absolute
	ResolvePath(path string) string

	Glob(patterns []string) ([]string, error)
}

FileResolver resolves and reads files

Jump to

Keyboard shortcuts

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