template

package
v0.0.0-...-834dad9 Latest Latest
Warning

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

Go to latest
Published: Jan 26, 2024 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrTemplateNotFound = errors.New("template not found")

ErrTemplateNotFound is the error returned when the template not found

Functions

This section is empty.

Types

type DefaultStorage

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

DefaultStorage is the default implementation of the template storage

func NewDefaultStorage

func NewDefaultStorage(tmpls ...Template) *DefaultStorage

NewDefaultStorage returns new default template storage

func (*DefaultStorage) RegisterTmpl

func (s *DefaultStorage) RegisterTmpl(tmpls ...Template)

RegisterTmpl registers the templates

func (*DefaultStorage) Template

func (s *DefaultStorage) Template(ctx context.Context, name string) (Template, error)

Template returns the template by name

type Storage

type Storage interface {
	Template(ctx context.Context, name string) (Template, error)
}

Storage is the storage for the templates and access to them by name

type Template

type Template interface {
	Name() string
	IsHTML() bool
	Subject(ctx context.Context, vars map[string]any) (string, error)
	Render(ctx context.Context, wr io.Writer, vars map[string]any) error
}

Template of the message to send

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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