emailtemplate

package
v0.0.0-...-6fab949 Latest Latest
Warning

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

Go to latest
Published: Aug 8, 2023 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 ParsedTemplate

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

ParsedTemplate is a struct that represents a parsed email template.

func (*ParsedTemplate) ReplaceData

func (p *ParsedTemplate) ReplaceData(data map[string]any)

ReplaceData replaces the template data.

type ParsedTemplateVersion

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

ParsedTemplateVersion is a struct that represents a parsed email template.

func (*ParsedTemplateVersion) Execute

Execute executes the template and returns a message. If the template defines a to ,cc, bcc templates the template data provided to these templates will contain the '_index' key with the index of the recipient.

func (*ParsedTemplateVersion) ReplaceData

func (p *ParsedTemplateVersion) ReplaceData(data map[string]any)

ReplaceData replaces the template data.

type ParsedTemplates

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

ParsedTemplates is a struct that represents a parsed email templates.

func ParseTemplates

func ParseTemplates(generalData map[string]any, templates ...*Template) (*ParsedTemplates, error)

ParseTemplates parses input templates and returns a ParsedTemplates struct.

func (*ParsedTemplates) Add

func (p *ParsedTemplates) Add(t *Template) error

Add adds a template to the ParsedTemplates struct.

func (*ParsedTemplates) AddVersion

func (p *ParsedTemplates) AddVersion(name string, version *TemplateVersion) error

AddVersion adds a template version to the ParsedTemplates struct.

func (*ParsedTemplates) Execute

Execute executes the template and returns a message.

func (*ParsedTemplates) Get

func (p *ParsedTemplates) Get(name string) (*ParsedTemplate, bool)

Get returns a template by name.

func (*ParsedTemplates) GetVersion

func (p *ParsedTemplates) GetVersion(name string, version string) (*ParsedTemplateVersion, bool)

GetVersion returns a template by name and version.

func (*ParsedTemplates) UpsertVersion

func (p *ParsedTemplates) UpsertVersion(name string, version *TemplateVersion) error

UpsertVersion inserts or updates a template version.

type Template

type Template struct {
	// Name is the unique template name.
	Name string

	// Versions is a list of template versions.
	Versions []TemplateVersion

	// DefaultData is a map of default template data values.
	// This value is optional. The data from general data will be used if not provided.
	DefaultData map[string]any
}

Template is a struct that represents an email template.

type TemplateVersion

type TemplateVersion struct {
	// Version is the version of the template.
	Version string

	// Content is the content of the template version.
	// The content should define the following sub-templates:
	// - from_t - the from address of the email
	// - to_t - the to address of the email
	// - cc_t - the cc address of the email
	// - bcc_t - the bcc address of the email
	// - subject_t - the subject of the email
	// - html_t - the html body of the email
	// - text_t - the text body of the email
	Content string

	// DefaultData is a map of default template data values.
	// The data from template, or general data will be used if not provided.
	DefaultData map[string]any
}

TemplateVersion is a struct that represents a template version.

Jump to

Keyboard shortcuts

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