hermes

package module
v2.2.1 Latest Latest
Warning

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

Go to latest
Published: Aug 11, 2020 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 Action

type Action struct {
	Instructions string
	Button       Button
	InviteCode   string
}

Action is anything the user can act on (i.e., click on a button, view an invite code)

type Body

type Body struct {
	Name         string   // The name of the contacted person
	Intros       []string // Intro sentences, first displayed in the email
	Dictionary   []Entry  // A list of key+value (useful for displaying parameters/settings/personal info)
	Table        Table    // Table is an table where you can put data (pricing grid, a bill, and so on)
	Actions      []Action // Actions are a list of actions that the user will be able to execute via a button click
	Outros       []string // Outro sentences, last displayed in the email
	Greeting     string   // Greeting for the contacted person (default to 'Hi')
	Signature    string   // Signature for the contacted person (default to 'Yours truly')
	Title        string   // Title replaces the greeting+name when set
	FreeMarkdown Markdown // Free markdown content that replaces all content other than header and footer
}

Body is the body of the email, containing all interesting data

type Button

type Button struct {
	Color     string
	TextColor string
	Text      string
	Link      string
}

Button defines an action to launch

type Columns

type Columns struct {
	CustomWidth     map[string]string
	CustomAlignment map[string]string
}

Columns contains meta-data for the different columns

type Default

type Default struct{}

Default is the theme by default

func (*Default) HTMLTemplate

func (dt *Default) HTMLTemplate() string

HTMLTemplate returns a Golang template that will generate an HTML email.

func (*Default) Name

func (dt *Default) Name() string

Name returns the name of the default theme

func (*Default) PlainTextTemplate

func (dt *Default) PlainTextTemplate() string

PlainTextTemplate returns a Golang template that will generate an plain text email.

type Email

type Email struct {
	Body Body
}

Email is the email containing a body

type Entry

type Entry struct {
	Key   string
	Value string
}

Entry is a simple entry of a map Allows using a slice of entries instead of a map Because Golang maps are not ordered

type Flat

type Flat struct{}

Flat is a theme

func (*Flat) HTMLTemplate

func (dt *Flat) HTMLTemplate() string

HTMLTemplate returns a Golang template that will generate an HTML email.

func (*Flat) Name

func (dt *Flat) Name() string

Name returns the name of the flat theme

func (*Flat) PlainTextTemplate

func (dt *Flat) PlainTextTemplate() string

PlainTextTemplate returns a Golang template that will generate an plain text email.

type Hermes

type Hermes struct {
	Theme              Theme
	TextDirection      TextDirection
	Product            Product
	DisableCSSInlining bool
}

Hermes is an instance of the hermes email generator

func (*Hermes) GenerateHTML

func (h *Hermes) GenerateHTML(email Email) (string, error)

GenerateHTML generates the email body from data to an HTML Reader This is for modern email clients

func (*Hermes) GeneratePlainText

func (h *Hermes) GeneratePlainText(email Email) (string, error)

GeneratePlainText generates the email body from data This is for old email clients

type Markdown

type Markdown template.HTML

Markdown is a HTML template (a string) representing Markdown content https://en.wikipedia.org/wiki/Markdown

func (Markdown) ToHTML

func (c Markdown) ToHTML() template.HTML

ToHTML converts Markdown to HTML

type Product

type Product struct {
	Name        string
	Link        string // e.g. https://matcornic.github.io
	Copyright   string // Copyright © 2019 Hermes. All rights reserved.
	TroubleText string // TroubleText is the sentence at the end of the email for users having trouble with the button (default to `If you’re having trouble with the button '{ACTION}', copy and paste the URL below into your web browser.`)
}

Product represents your company product (brand) Appears in header & footer of e-mails

type Table

type Table struct {
	Data    [][]Entry // Contains data
	Columns Columns   // Contains meta-data for display purpose (width, alignement)
}

Table is an table where you can put data (pricing grid, a bill, and so on)

type Template

type Template struct {
	Hermes Hermes
	Email  Email
}

Template is the struct given to Golang templating Root object in a template is this struct

type TextDirection

type TextDirection string

TextDirection of the text in HTML email

const TDLeftToRight TextDirection = "ltr"

TDLeftToRight is the text direction from left to right (default)

const TDRightToLeft TextDirection = "rtl"

TDRightToLeft is the text direction from right to left

type Theme

type Theme interface {
	Name() string              // The name of the theme
	HTMLTemplate() string      // The golang template for HTML emails
	PlainTextTemplate() string // The golang templte for plain text emails (can be basic HTML)
}

Theme is an interface to implement when creating a new theme

Jump to

Keyboard shortcuts

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