hermes: github.com/matcornic/hermes Index | Files | Directories

package hermes

import "github.com/matcornic/hermes"

Index

Package Files

default.go flat.go hermes.go

type Action Uses

type Action struct {
    Instructions string
    Button       Button
}

Action is an action the user can do on the email (click on a button)

type Body Uses

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 Uses

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

Button defines an action to launch

type Columns Uses

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

Columns contains meta-data for the different columns

type Default Uses

type Default struct{}

Default is the theme by default

func (*Default) HTMLTemplate Uses

func (dt *Default) HTMLTemplate() string

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

func (*Default) Name Uses

func (dt *Default) Name() string

Name returns the name of the default theme

func (*Default) PlainTextTemplate Uses

func (dt *Default) PlainTextTemplate() string

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

type Email Uses

type Email struct {
    Body Body
}

Email is the email containing a body

type Entry Uses

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 Uses

type Flat struct{}

Flat is a theme

func (*Flat) HTMLTemplate Uses

func (dt *Flat) HTMLTemplate() string

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

func (*Flat) Name Uses

func (dt *Flat) Name() string

Name returns the name of the flat theme

func (*Flat) PlainTextTemplate Uses

func (dt *Flat) PlainTextTemplate() string

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

type Hermes Uses

type Hermes struct {
    Theme         Theme
    TextDirection TextDirection
    Product       Product
}

Hermes is an instance of the hermes email generator

func (*Hermes) GenerateHTML Uses

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 Uses

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

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

type Markdown Uses

type Markdown template.HTML

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

func (Markdown) ToHTML Uses

func (c Markdown) ToHTML() template.HTML

ToHTML converts Markdown to HTML

type Product Uses

type Product struct {
    Name        string
    Link        string // e.g. https://matcornic.github.io
            string // e.g. https://matcornic.github.io/img/logo.png
    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 Uses

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 Uses

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 Uses

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 Uses

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

Directories

PathSynopsis
examples

Package hermes imports 6 packages (graph) and is imported by 11 packages. Updated 2019-02-27. Refresh now. Tools for package owners.