template

package
v0.9.2 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2025 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Template

type Template[T any] struct {
	// contains filtered or unexported fields
}

Template provides template execution and data embedding/extraction capabilities. It is parameterized by type T which represents the data type to be embedded/extracted.

func New

func New[T any](identity string, markerSuffix string, entityType string) (*Template[T], error)

New creates a new Template instance with the specified identity, markerSuffix, and entityType. The identity distinguishes between different manager instances. The markerSuffix differentiates between different entity types (e.g., "-pr-data" or "-issue-data"). The entityType is used in error messages (e.g., "PR" or "issue"). Returns an error if identity validation fails or regex compilation fails.

func (*Template[T]) Embed

func (t *Template[T]) Embed(body string, data *T) (string, error)

Embed embeds the given data as JSON in HTML comments within the body. The embedded data is placed at the end of the body using the configured marker.

func (*Template[T]) Execute

func (t *Template[T]) Execute(tmpl *template.Template, data *T) (string, error)

Execute executes the given template with the provided data.

func (*Template[T]) Extract

func (t *Template[T]) Extract(body string) (*T, error)

Extract extracts embedded data from the body text. Returns an error if the data cannot be found or parsed.

Jump to

Keyboard shortcuts

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