diff --git a/default.go b/default.go index 2ec8d4f..3af764b 100644 --- a/default.go +++ b/default.go @@ -285,12 +285,16 @@ func (dt *Default) HTMLTemplate() string {

{{if .Email.Body.Title }}{{ .Email.Body.Title }}{{ else }}{{ .Email.Body.Greeting }} {{ .Email.Body.Name }},{{ end }}

- {{ with .Email.Body.Intros }} + {{ if (ne .Email.Body.IntrosMarkdown "") }} + {{ .Email.Body.IntrosMarkdown.ToHTML }} + {{ else }} + {{ with .Email.Body.Intros }} {{ if gt (len .) 0 }} {{ range $line := . }}

{{ $line }}

{{ end }} {{ end }} + {{ end }} {{ end }} {{ if (ne .Email.Body.FreeMarkdown "") }} {{ .Email.Body.FreeMarkdown.ToHTML }} @@ -379,17 +383,24 @@ func (dt *Default) HTMLTemplate() string { {{ end }} {{ end }} - {{ with .Email.Body.Outros }} + {{ if (ne .Email.Body.OutrosMarkdown "") }} + {{ .Email.Body.OutrosMarkdown.ToHTML }} + {{ else }} + {{ with .Email.Body.Outros }} {{ if gt (len .) 0 }} {{ range $line := . }}

{{ $line }}

{{ end }} {{ end }} {{ end }} + {{ end }}

{{.Email.Body.Signature}},
+ {{ if (ne .Email.Body.SignatureName "") }} + {{.Email.Body.SignatureName}}
+ {{ end }} {{.Hermes.Product.Name}}

@@ -439,9 +450,13 @@ func (dt *Default) HTMLTemplate() string { // PlainTextTemplate returns a Golang template that will generate an plain text email. func (dt *Default) PlainTextTemplate() string { return `

{{if .Email.Body.Title }}{{ .Email.Body.Title }}{{ else }}{{ .Email.Body.Greeting }} {{ .Email.Body.Name }},{{ end }}

-{{ with .Email.Body.Intros }} - {{ range $line := . }} -

{{ $line }}

+{{ if (ne .Email.Body.IntrosMarkdown "") }} + {{ .Email.Body.IntrosMarkdown.ToHTML }} +{{ else }} + {{ with .Email.Body.Intros }} + {{ range $line := . }} +

{{ $line }}

+ {{ end }} {{ end }} {{ end }} {{ if (ne .Email.Body.FreeMarkdown "") }} @@ -483,12 +498,23 @@ func (dt *Default) PlainTextTemplate() string { {{ end }} {{ end }} {{ end }} -{{ with .Email.Body.Outros }} - {{ range $line := . }} -

{{ $line }}

+{{ if (ne .Email.Body.OutrosMarkdown "") }} + {{ .Email.Body.OutrosMarkdown.ToHTML }} +{{ else }} + {{ with .Email.Body.Outros }} + {{ range $line := . }} +

{{ $line }}

+ {{ end }} {{ end }} {{ end }} -

{{.Email.Body.Signature}},
{{.Hermes.Product.Name}} - {{.Hermes.Product.Link}}

+

+ {{.Email.Body.Signature}}, +
+ {{ if (ne .Email.Body.SignatureName "") }} + {{.Email.Body.SignatureName}}
+ {{ end }} + {{.Hermes.Product.Name}} - {{.Hermes.Product.Link}} +

{{.Hermes.Product.Copyright}}

` diff --git a/flat.go b/flat.go index 26a4f32..9caa45b 100644 --- a/flat.go +++ b/flat.go @@ -285,12 +285,16 @@ func (dt *Flat) HTMLTemplate() string {

{{if .Email.Body.Title }}{{ .Email.Body.Title }}{{ else }}{{ .Email.Body.Greeting }} {{ .Email.Body.Name }},{{ end }}

- {{ with .Email.Body.Intros }} + {{ if (ne .Email.Body.IntrosMarkdown "") }} + {{ .Email.Body.IntrosMarkdown.ToHTML }} + {{ else }} + {{ with .Email.Body.Intros }} {{ if gt (len .) 0 }} {{ range $line := . }}

{{ $line }}

{{ end }} {{ end }} + {{ end }} {{ end }} {{ if (ne .Email.Body.FreeMarkdown "") }} {{ .Email.Body.FreeMarkdown.ToHTML }} @@ -379,17 +383,24 @@ func (dt *Flat) HTMLTemplate() string { {{ end }} {{ end }} - {{ with .Email.Body.Outros }} + {{ if (ne .Email.Body.OutrosMarkdown "") }} + {{ .Email.Body.OutrosMarkdown.ToHTML }} + {{ else }} + {{ with .Email.Body.Outros }} {{ if gt (len .) 0 }} {{ range $line := . }}

{{ $line }}

{{ end }} {{ end }} {{ end }} + {{ end }}

{{.Email.Body.Signature}},
+ {{ if (ne .Email.Body.SignatureName "") }} + {{.Email.Body.SignatureName}}
+ {{ end }} {{.Hermes.Product.Name}}

@@ -439,9 +450,13 @@ func (dt *Flat) HTMLTemplate() string { // PlainTextTemplate returns a Golang template that will generate an plain text email. func (dt *Flat) PlainTextTemplate() string { return `

{{if .Email.Body.Title }}{{ .Email.Body.Title }}{{ else }}{{ .Email.Body.Greeting }} {{ .Email.Body.Name }}{{ end }},

-{{ with .Email.Body.Intros }} - {{ range $line := . }} -

{{ $line }}

+{{ if (ne .Email.Body.IntrosMarkdown "") }} + {{ .Email.Body.IntrosMarkdown.ToHTML }} +{{ else }} + {{ with .Email.Body.Intros }} + {{ range $line := . }} +

{{ $line }}

+ {{ end }} {{ end }} {{ end }} {{ if (ne .Email.Body.FreeMarkdown "") }} @@ -483,12 +498,23 @@ func (dt *Flat) PlainTextTemplate() string { {{ end }} {{ end }} {{ end }} -{{ with .Email.Body.Outros }} - {{ range $line := . }} -

{{ $line }}

+{{ if (ne .Email.Body.OutrosMarkdown "") }} + {{ .Email.Body.OutrosMarkdown.ToHTML }} +{{ else }} + {{ with .Email.Body.Outros }} + {{ range $line := . }} +

{{ $line }}

+ {{ end }} {{ end }} {{ end }} -

{{.Email.Body.Signature}},
{{.Hermes.Product.Name}} - {{.Hermes.Product.Link}}

+

+ {{.Email.Body.Signature}}, +
+ {{ if (ne .Email.Body.SignatureName "") }} + {{.Email.Body.SignatureName}}
+ {{ end }} + {{.Hermes.Product.Name}} - {{.Hermes.Product.Link}} +

{{.Hermes.Product.Copyright}}

` diff --git a/hermes.go b/hermes.go index f01fc45..5a2554b 100644 --- a/hermes.go +++ b/hermes.go @@ -59,16 +59,19 @@ type Markdown template.HTML // Body is the body of the email, containing all interesting data 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 + Name string // The name of the contacted person + Intros []string // Intro sentences, first displayed in the email + IntrosMarkdown Markdown // Intro in markdown, will override Intros + 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 + OutrosMarkdown Markdown // Outro in markdown, will override Outros + Greeting string // Greeting for the contacted person (default to 'Hi') + Signature string // Signature for the contacted person (default to 'Yours truly') + SignatureName string // Contact person name + Title string // Title replaces the greeting+name when set + FreeMarkdown Markdown // Free markdown content that replaces all content other than header and footer } // ToHTML converts Markdown to HTML