template

package
v0.92.1 Latest Latest
Warning

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

Go to latest
Published: Jun 6, 2026 License: GPL-3.0 Imports: 8 Imported by: 0

Documentation

Overview

Package template provides notification template rendering using Go text/template with Sprig function library support.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Init

func Init() error

Init loads templates from configuration into the global engine. It is safe to call multiple times (on config reload).

Types

type Engine

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

Engine renders notification templates for different channels using Sprig functions.

func GetEngine

func GetEngine() *Engine

GetEngine returns the global template engine.

func New

func New() *Engine

New creates a new template Engine.

func (*Engine) GetTemplateID

func (e *Engine) GetTemplateID(eventType string) string

GetTemplateID returns the template ID for a given event type. This is a convenience mapping that can be extended.

func (*Engine) HasTemplate

func (e *Engine) HasTemplate(id string) bool

HasTemplate returns true if the given template ID exists in the engine.

func (*Engine) ListTemplateIDs

func (e *Engine) ListTemplateIDs() []string

ListTemplateIDs returns all registered template IDs in the engine.

func (*Engine) LoadConfig

func (e *Engine) LoadConfig(templates []config.NotifyTemplate) error

LoadConfig loads templates from notify configuration and compiles all templates.

func (*Engine) Render

func (e *Engine) Render(templateID, channel string, data map[string]any) (*RenderResult, error)

Render renders a template by ID for a specific channel with the given data payload. It first looks for a channel-specific override, falling back to the default template.

type RenderResult

type RenderResult struct {
	Title  string
	Body   string
	Format string
}

RenderResult holds the output of template rendering for a specific channel.

Jump to

Keyboard shortcuts

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