template

package
v0.5.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetAllBuiltinTemplates

func GetAllBuiltinTemplates() (map[TemplateType]map[string]string, error)

GetAllBuiltinTemplates returns a map of all builtin templates (used for testing/docs) Returns map[type][name]content

func GetBuiltinChangelogTemplate

func GetBuiltinChangelogTemplate(name string) (string, error)

GetBuiltinChangelogTemplate retrieves a builtin changelog template by name

func GetBuiltinCommitTemplate

func GetBuiltinCommitTemplate(name string) (string, error)

GetBuiltinCommitTemplate retrieves a builtin commit message template by name

func GetBuiltinReleaseNotesTemplate

func GetBuiltinReleaseNotesTemplate(name string) (string, error)

GetBuiltinReleaseNotesTemplate retrieves a builtin release notes template by name

func GetBuiltinReleaseTemplate

func GetBuiltinReleaseTemplate(name string) (string, error)

GetBuiltinReleaseTemplate retrieves a builtin release template by name

func GetBuiltinTagTemplate

func GetBuiltinTagTemplate(name string) (string, error)

GetBuiltinTagTemplate retrieves a builtin tag template by name

func GetBuiltinTemplate

func GetBuiltinTemplate(templateType TemplateType, name string) (string, error)

GetBuiltinTemplate retrieves a builtin template by type and name

func GetDefaultChangelogTemplate

func GetDefaultChangelogTemplate() (string, error)

GetDefaultChangelogTemplate returns the default changelog template

func GetDefaultCommitTemplate

func GetDefaultCommitTemplate() (string, error)

GetDefaultCommitTemplate returns the default commit message template

func GetDefaultReleaseNotesTemplate

func GetDefaultReleaseNotesTemplate() (string, error)

GetDefaultReleaseNotesTemplate returns the default release notes template

func GetDefaultReleaseTemplate

func GetDefaultReleaseTemplate() (string, error)

GetDefaultReleaseTemplate returns the default release template

func GetDefaultTagTemplate

func GetDefaultTagTemplate() (string, error)

GetDefaultTagTemplate returns the default tag template

func ListBuiltinTemplates

func ListBuiltinTemplates(templateType TemplateType) ([]string, error)

ListBuiltinTemplates lists available builtin templates for a given type

func MustParse

func MustParse(name, content string) *template.Template

MustParse parses a template and panics on error (useful for built-in templates)

func ParseWithFunctions

func ParseWithFunctions(name, content string, funcMap template.FuncMap) (*template.Template, error)

ParseWithFunctions parses a template with custom functions

func RenderReleaseNotes

func RenderReleaseNotes(entries []history.Entry) (string, error)

RenderReleaseNotes renders release notes using the default template

func RenderReleaseNotesWithTemplate

func RenderReleaseNotesWithTemplate(entries []history.Entry, templateSource string) (string, error)

RenderReleaseNotesWithTemplate renders release notes using a specific template templateSource can be: - "builtin:default" or "builtin:grouped" - builtin templates - "file:/path/to/template.tmpl" - file path - "https://example.com/template.tmpl" - remote URL - inline template content (multiline string) - "changelog" - auto-maps to changelog template for multi-version - "release-notes" - auto-maps to release-notes template for single-version

Types

type SourceType

type SourceType int

SourceType represents the type of template source

const (
	SourceTypeBuiltin SourceType = iota
	SourceTypeFile
	SourceTypeGit
	SourceTypeHTTPS
	SourceTypeInline
)

func DetectSourceType

func DetectSourceType(source string) (SourceType, string)

DetectSourceType detects the template source type and extracts the target

type TemplateLoader

type TemplateLoader struct {
	// contains filtered or unexported fields
}

TemplateLoader handles loading templates from various sources

func NewTemplateLoader

func NewTemplateLoader() *TemplateLoader

NewTemplateLoader creates a new template loader

func (*TemplateLoader) GetAuthToken

func (l *TemplateLoader) GetAuthToken() string

GetAuthToken returns the current authentication token

func (*TemplateLoader) Load

func (l *TemplateLoader) Load(source string, expectedType ...TemplateType) (string, error)

Load loads a template from the specified source For builtin templates, expectedType specifies which type directory to search

func (*TemplateLoader) LoadInline

func (l *TemplateLoader) LoadInline(content string) (string, error)

LoadInline loads an inline template (no source prefix parsing)

func (*TemplateLoader) SetAuthToken

func (l *TemplateLoader) SetAuthToken(token string)

SetAuthToken sets the authentication token for remote sources

func (*TemplateLoader) SetBaseDir

func (l *TemplateLoader) SetBaseDir(dir string)

SetBaseDir sets the base directory for resolving relative file paths

func (*TemplateLoader) SetTimeout

func (l *TemplateLoader) SetTimeout(timeout time.Duration)

SetTimeout sets the timeout for remote operations

type TemplateParser

type TemplateParser struct {
	// contains filtered or unexported fields
}

TemplateParser handles parsing go templates with Sprig functions

func NewTemplateParser

func NewTemplateParser() *TemplateParser

NewTemplateParser creates a new template parser with safe Sprig functions

func (*TemplateParser) AddFunction

func (p *TemplateParser) AddFunction(name string, fn interface{})

AddFunction adds a custom function to the function map

func (*TemplateParser) Parse

func (p *TemplateParser) Parse(name, content string) (*template.Template, error)

Parse parses a template string and returns a compiled template

func (*TemplateParser) SetOption

func (p *TemplateParser) SetOption(key, value string)

SetOption sets a template option (e.g., "missingkey=error")

type TemplateRenderer

type TemplateRenderer struct {
	// contains filtered or unexported fields
}

TemplateRenderer handles rendering templates with context and timeout

func NewTemplateRenderer

func NewTemplateRenderer() *TemplateRenderer

NewTemplateRenderer creates a new template renderer

func (*TemplateRenderer) MustRender

func (r *TemplateRenderer) MustRender(templateContent string, ctx interface{}) string

MustRender renders a template and panics on error (useful for testing)

func (*TemplateRenderer) Render

func (r *TemplateRenderer) Render(templateContent string, ctx interface{}) (string, error)

Render renders a template string with the given context

func (*TemplateRenderer) RenderParsed

func (r *TemplateRenderer) RenderParsed(tmpl *template.Template, ctx interface{}) (string, error)

RenderParsed renders a pre-parsed template with the given context

func (*TemplateRenderer) RenderWithName

func (r *TemplateRenderer) RenderWithName(name, templateContent string, ctx interface{}) (string, error)

RenderWithName renders a template with a specific name (useful for error messages)

func (*TemplateRenderer) SetTimeout

func (r *TemplateRenderer) SetTimeout(timeout time.Duration)

SetTimeout sets the maximum time allowed for template rendering

type TemplateType

type TemplateType string

TemplateType represents the type/purpose of a template

const (
	TemplateTypeChangelog    TemplateType = "changelog"
	TemplateTypeTag          TemplateType = "tag"
	TemplateTypeRelease      TemplateType = "release"
	TemplateTypeReleaseNotes TemplateType = "releasenotes"
	TemplateTypeCommit       TemplateType = "commit"
)

Jump to

Keyboard shortcuts

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