From 8c8ad36f4ad2fd3507eb78303abf473c1b955066 Mon Sep 17 00:00:00 2001 From: Thibaut Rousseau Date: Sat, 1 Apr 2017 21:50:09 +0200 Subject: [PATCH 1/4] chore: Remove Mailgen references --- CONTRIBUTING.md | 6 +++--- README.md | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index dead767..81e1d47 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -14,7 +14,7 @@ Excellent! You've come to the right place. ## Theming Instructions -This file contains instructions on adding themes to Mailgen: +This file contains instructions on adding themes to Hermes: * [Using a Custom Theme](#using-a-custom-theme) * [Creating a Built-In Theme](#creating-a-built-in-theme) @@ -26,7 +26,7 @@ This file contains instructions on adding themes to Mailgen: ### Using a Custom Theme -If you want to supply your own **custom theme** for Hermes to use (but don't want it included with Mailgen): +If you want to supply your own **custom theme** for Hermes to use (but don't want it included with Hermes): 1. Create a new struct implementing `Theme` interface ([hermes.go](hermes.go)). A real-life example is in [default.go](default.go) 2. Supply your new theme at hermes creation @@ -68,7 +68,7 @@ h := hermes.Hermes{ ### Creating a Built-In Theme -If you want to create a new **built-in** Mailgen theme: +If you want to create a new **built-in** Hermes theme: 1. Fork the repository to your GitHub account and clone it to your computer 2. Create a new Go file named after your new theme diff --git a/README.md b/README.md index b4b5a7d..d7fbeda 100644 --- a/README.md +++ b/README.md @@ -146,7 +146,7 @@ To use a custom title string rather than a greeting/name introduction, provide i email := hermes.Email{ Body: hermes.Body{ // Title will override `Name` - Title: "Welcome to Mailgen", + Title: "Welcome to Hermes", }, } ``` From 1c0c9b9686d4af883f2f5d8f98ce7a053f7be39a Mon Sep 17 00:00:00 2001 From: Thibaut Rousseau Date: Sat, 1 Apr 2017 21:58:19 +0200 Subject: [PATCH 2/4] chore: fix typos --- README.md | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index d7fbeda..ffc57cd 100644 --- a/README.md +++ b/README.md @@ -5,8 +5,8 @@ [![Go Coverage](https://codecov.io/github/matcornic/hermes/coverage.svg)](https://codecov.io/github/matcornic/hermes/) [![Godoc](https://godoc.org/github.com/matcornic/hermes?status.svg)](https://godoc.org/github.com/matcornic/hermes) -Hermes is the Go port of the great [mailgen](https://github.com/eladnava/mailgen) engine for Node.js. Check their work, it's awesome ! -It's a package that generates clean, responsive HTML e-mails for sending transactional e-mails (welcome e-mail, reset password e-mails, receipt e-mails and so on). +Hermes is the Go port of the great [mailgen](https://github.com/eladnava/mailgen) engine for Node.js. Check their work, it's awesome! +It's a package that generates clean, responsive HTML e-mails for sending transactional e-mails (welcome e-mails, reset password e-mails, receipt e-mails and so on). # Demo @@ -31,8 +31,8 @@ h := hermes.Hermes{ // Appears in header & footer of e-mails Name: "Hermes", Link: "https://example-hermes.com/", - //Option product logo - //Logo: "http://www.duchess-france.org/wp-content/uploads/2016/01/gopher.png", + // Option product logo + // Logo: "http://www.duchess-france.org/wp-content/uploads/2016/01/gopher.png", }, } ``` @@ -62,7 +62,7 @@ email := hermes.Email{ }, } -// Generate an HTML email with the provided contents(for modern clients) +// Generate an HTML email with the provided contents (for modern clients) emailBody, err := h.GenerateHTML(email) if err != nil { panic(err) // Tip: Handle error with something else than a panic ;) @@ -74,7 +74,7 @@ if err != nil { panic(err) // Tip: Handle error with something else than a panic ;) } -// Optionnaly, preview the generated HTML e-mail by writing it to a local file +// Optionally, preview the generated HTML e-mail by writing it to a local file err = ioutil.WriteFile("preview.html", []byte(emailBody), 0644) if err != nil { panic(err) // Tip: Handle error with something else than a panic ;) @@ -129,13 +129,13 @@ h := hermes.Hermes { ## Language Customizations -To customize the e-mail greeting (Hi) or signature (Yours truly), supply custom strings within the e-mail `Body`: +To customize the e-mail's greeting ("Hi") or signature ("Yours truly"), supply custom strings within the e-mail's `Body`: ```go email := hermes.Email{ Body: hermes.Body{ Greeting: "Dear", - Signature: "Sincerly", + Signature: "Sincerely", }, } ``` @@ -176,7 +176,6 @@ Hermes supports injecting custom elements such as dictionaries, tables and actio To inject an action button in to the e-mail, supply the `Actions` object as follows: - ```go email := hermes.Email{ Body: hermes.Body{ From f983d8d7c57608c7e4d00271da55629f322c80c3 Mon Sep 17 00:00:00 2001 From: Thibaut Rousseau Date: Sat, 1 Apr 2017 22:00:44 +0200 Subject: [PATCH 3/4] chore: remove absolute URLs for screenshots --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index ffc57cd..d3eba58 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ It's a package that generates clean, responsive HTML e-mails for sending transac # Demo - + # Usage @@ -83,7 +83,7 @@ if err != nil { This code would output the following HTML template: - + > Theme templates will be embedded in your application binary. If you want to use external templates (for configuration), use your own theme by implementing `hermes.Theme` interface with code searching for your files. @@ -113,7 +113,7 @@ The following open-source themes are bundled with this package: * `default` by [Postmark Transactional Email Templates](https://github.com/wildbit/postmark-templates) - + ## RTL Support From 8ffbdf73058c76149cf831e52025187561300b10 Mon Sep 17 00:00:00 2001 From: Thibaut Rousseau Date: Sat, 1 Apr 2017 22:34:29 +0200 Subject: [PATCH 4/4] style: Fix indentation of the theme --- default.go | 218 +++++++++++++++++++++++++++-------------------------- hermes.go | 2 +- 2 files changed, 112 insertions(+), 108 deletions(-) diff --git a/default.go b/default.go index e6e4218..9208cab 100644 --- a/default.go +++ b/default.go @@ -227,6 +227,7 @@ func (dt *Default) HTMLTemplate() string { + @@ -235,121 +236,124 @@ 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 gt (len .) 0 }} - {{ range $line := . }} -

{{ $line }}

- {{ end }} - {{ end }} - {{ end }} + {{ with .Email.Body.Intros }} + {{ if gt (len .) 0 }} + {{ range $line := . }} +

{{ $line }}

+ {{ end }} + {{ end }} + {{ end }} - {{ with .Email.Body.Dictionary }} - {{ if gt (len .) 0 }} -
- {{ range $entry := . }} -
{{ $entry.Key }}:
-
{{ $entry.Value }}
- {{ end }} -
- {{ end }} - {{ end }} + {{ with .Email.Body.Dictionary }} + {{ if gt (len .) 0 }} +
+ {{ range $entry := . }} +
{{ $entry.Key }}:
+
{{ $entry.Value }}
+ {{ end }} +
+ {{ end }} + {{ end }} - - {{ with .Email.Body.Table }} - {{ $data := .Data }} - {{ $columns := .Columns }} - {{ if gt (len $data) 0 }} - - - - -
- + + {{ with .Email.Body.Table }} + {{ $data := .Data }} + {{ $columns := .Columns }} + {{ if gt (len $data) 0 }} +
+ + + +
+ + + {{ $col := index $data 0 }} + {{ range $entry := $col }} + + {{ end }} + + {{ range $row := $data }} + + {{ range $cell := $row }} + + {{ end }} + + {{ end }} +
+

{{ $entry.Key }}

+
+ {{ $cell.Value }} +
+
+ {{ end }} + {{ end }} + + + {{ with .Email.Body.Actions }} + {{ if gt (len .) 0 }} + {{ range $action := . }} +

{{ $action.Instructions }}

+ - {{ $col := index $data 0 }} - {{ range $entry := $col }} - - {{ end }} + - {{ range $row := $data }} - - {{ range $cell := $row }} - - {{ end }} - - {{ end }}
-

{{ $entry.Key }}

-
+ +
- {{ $cell.Value }} -
-
- {{ end }} - {{ end }} + {{ end }} + {{ end }} + {{ end }} - - {{ with .Email.Body.Actions }} - {{ if gt (len .) 0 }} - {{ range $action := . }} -

{{ $action.Instructions }}

- - - - -
- -
- {{ end }} - {{ end }} - {{ end }} + {{ with .Email.Body.Outros }} + {{ if gt (len .) 0 }} + {{ range $line := . }} +

{{ $line }}

+ {{ end }} + {{ end }} + {{ end }} - {{ with .Email.Body.Outros }} - {{ if gt (len .) 0 }} - {{ range $line := . }} -

{{ $line }}

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

+ {{.Email.Body.Signature}}, +
+ {{.Hermes.Product.Name}} +

-

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

- - {{ with .Email.Body.Actions }} - - - {{ range $action := . }} - - {{ end }} - - -
-

If you’re having trouble with the button '{{ $action.Button.Text }}', copy and paste the URL below into your web browser.

-

{{ $action.Button.Link }}

-
- {{ end }} + {{ with .Email.Body.Actions }} + + + + {{ range $action := . }} + + {{ end }} + + +
+

If you’re having trouble with the button '{{ $action.Button.Text }}', copy and paste the URL below into your web browser.

+

{{ $action.Button.Link }}

+
+ {{ end }} diff --git a/hermes.go b/hermes.go index 49cad10..374ca20 100644 --- a/hermes.go +++ b/hermes.go @@ -124,7 +124,7 @@ func setDefaultHermesValues(h *Hermes) error { Copyright: "Copyright © 2017 Hermes. All rights reserved.", }, } - // Merge the given hermes engine coniguration with default one + // Merge the given hermes engine configuration with default one // Default one overrides all zero values err := mergo.Merge(h, defaultHermes) if err != nil {