template

package
v1.9.0 Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Manager

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

Manager handles template loading and rendering

func NewManager

func NewManager(templateDir string) *Manager

NewManager creates a new template manager

func (*Manager) GetBundle added in v0.4.0

func (m *Manager) GetBundle() *i18n.Bundle

GetBundle returns the i18n bundle for external use

func (*Manager) GetPurposeName added in v0.4.0

func (m *Manager) GetPurposeName(locale, purpose string) string

GetPurposeName returns the localized name for a purpose

func (*Manager) LoadProblems added in v1.7.0

func (m *Manager) LoadProblems() []string

LoadProblems returns one description for every file or directory under the template directory that could not be loaded or can never be selected. The manager still works without them (it falls back to the built-in text), so the caller is expected to log these.

func (*Manager) Render

func (m *Manager) Render(locale, channel, purpose string, data TemplateData) (string, error)

Render renders a template with the given data

func (*Manager) RenderEmail

func (m *Manager) RenderEmail(locale, purpose string, data TemplateData) (subject, body string, err error)

RenderEmail renders an email template and returns subject and body

func (*Manager) RenderSMS

func (m *Manager) RenderSMS(locale, purpose string, data TemplateData) (body string, err error)

RenderSMS renders an SMS template and returns the message body

type TemplateData

type TemplateData struct {
	Code      string
	ExpiresIn int // seconds
	Purpose   string
	Locale    string
}

TemplateData represents the data available in templates

Jump to

Keyboard shortcuts

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