-
-
+
+
+
+
+
+
@@ -175,12 +181,14 @@ Hi Jon Sn
+
If you’re having trouble with the button 'Go to Dashboard', copy and paste the URL below into your web browser.
https://hermes-example.com/dashboard
|
+
diff --git a/examples/default/default.reset.html b/examples/default/default.reset.html
index e4f3e93..f7ee77e 100644
--- a/examples/default/default.reset.html
+++ b/examples/default/default.reset.html
@@ -70,35 +70,41 @@ Hi Jon Sn
-
-
-
-
-
-
+
+
+
+
+
+
@@ -123,12 +129,14 @@ Hi Jon Sn
+
If you’re having trouble with the button 'Reset your password', copy and paste the URL below into your web browser.
https://hermes-example.com/reset-password?token=d9729feb74992cc3482b350163a1a010
|
+
diff --git a/examples/default/default.welcome.html b/examples/default/default.welcome.html
index dbafd02..15fc274 100644
--- a/examples/default/default.welcome.html
+++ b/examples/default/default.welcome.html
@@ -85,35 +85,41 @@ Hi Jon Sn
-
-
-
-
-
-
+
+
+
+
+
+
@@ -138,12 +144,14 @@ Hi Jon Sn
+
If you’re having trouble with the button 'Confirm your account', copy and paste the URL below into your web browser.
https://hermes-example.com/confirm?token=d9729feb74992cc3482b350163a1a010
|
+
diff --git a/examples/flat/flat.invite_code.html b/examples/flat/flat.invite_code.html
new file mode 100644
index 0000000..d557ad2
--- /dev/null
+++ b/examples/flat/flat.invite_code.html
@@ -0,0 +1,153 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ |
+
+
+
+
+
+
+
+
+
+ Hi Jon Snow,
+
+
+
+ Welcome to Hermes! We're very excited to have you on board.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Please copy your invite code:
+
+
+
+
+
+
+
+
+ 123456
+
+
+ |
+
+
+
+
+
+
+
+
+
+
+
+ Need help, or have questions? Just reply to this email, we'd love to help.
+
+
+
+
+
+ Yours truly,
+
+ Hermes
+
+
+
+
+
+
+
+ |
+
+
+ |
+
+
+
+
+ |
+
+
+ |
+
+
+
+
+
\ No newline at end of file
diff --git a/examples/flat/flat.invite_code.txt b/examples/flat/flat.invite_code.txt
new file mode 100644
index 0000000..3ffd46d
--- /dev/null
+++ b/examples/flat/flat.invite_code.txt
@@ -0,0 +1,14 @@
+------------
+Hi Jon Snow,
+------------
+
+Welcome to Hermes! We're very excited to have you on board.
+
+Please copy your invite code: 123456
+
+Need help, or have questions? Just reply to this email, we'd love to help.
+
+Yours truly,
+Hermes - https://example-hermes.com/
+
+Copyright © 2020 Hermes. All rights reserved.
\ No newline at end of file
diff --git a/examples/flat/flat.receipt.html b/examples/flat/flat.receipt.html
index a602276..d05aa32 100644
--- a/examples/flat/flat.receipt.html
+++ b/examples/flat/flat.receipt.html
@@ -121,6 +121,7 @@ Hi Jon Sn
You can check the status of your order and more in your dashboard:
-
-
+
+
@@ -167,6 +173,7 @@ Hi Jon Sn
+
If you’re having trouble with the button 'Go to Dashboard', copy and paste the URL below into your web browser.
@@ -174,6 +181,7 @@ Hi Jon Sn
|
+
diff --git a/examples/flat/flat.reset.html b/examples/flat/flat.reset.html
index f0f64a2..e6dc621 100644
--- a/examples/flat/flat.reset.html
+++ b/examples/flat/flat.reset.html
@@ -63,6 +63,7 @@ Hi Jon Sn
Click the button below to reset your password:
-
-
+
+
@@ -115,6 +121,7 @@ Hi Jon Sn
+
If you’re having trouble with the button 'Reset your password', copy and paste the URL below into your web browser.
@@ -122,6 +129,7 @@ Hi Jon Sn
|
+
diff --git a/examples/flat/flat.welcome.html b/examples/flat/flat.welcome.html
index a6a762c..988dbfb 100644
--- a/examples/flat/flat.welcome.html
+++ b/examples/flat/flat.welcome.html
@@ -78,6 +78,7 @@ Hi Jon Sn
To get started with Hermes, please click here:
-
-
+
+
@@ -130,6 +136,7 @@ Hi Jon Sn
+
If you’re having trouble with the button 'Confirm your account', copy and paste the URL below into your web browser.
@@ -137,6 +144,7 @@ Hi Jon Sn
|
+
diff --git a/examples/invite_code.go b/examples/invite_code.go
new file mode 100644
index 0000000..fb39caf
--- /dev/null
+++ b/examples/invite_code.go
@@ -0,0 +1,32 @@
+package main
+
+import (
+ "github.com/matcornic/hermes/v2"
+)
+
+type inviteCode struct {
+}
+
+func (w *inviteCode) Name() string {
+ return "invite_code"
+}
+
+func (w *inviteCode) Email() hermes.Email {
+ return hermes.Email{
+ Body: hermes.Body{
+ Name: "Jon Snow",
+ Intros: []string{
+ "Welcome to Hermes! We're very excited to have you on board.",
+ },
+ Actions: []hermes.Action{
+ {
+ Instructions: "Please copy your invite code:",
+ InviteCode: "123456",
+ },
+ },
+ Outros: []string{
+ "Need help, or have questions? Just reply to this email, we'd love to help.",
+ },
+ },
+ }
+}
diff --git a/examples/main.go b/examples/main.go
index edd3054..dcf8761 100644
--- a/examples/main.go
+++ b/examples/main.go
@@ -33,6 +33,7 @@ func main() {
new(reset),
new(receipt),
new(maintenance),
+ new(inviteCode),
}
themes := []hermes.Theme{
diff --git a/flat.go b/flat.go
index 1e4949b..13992a6 100644
--- a/flat.go
+++ b/flat.go
@@ -240,7 +240,10 @@ func (dt *Flat) HTMLTemplate() string {
/* Invite Code ------------------------------ */
.invite-code {
display: inline-block;
- padding: 20px 36px 16px 36px;
+ padding-top: 20px;
+ padding-right: 36px;
+ padding-bottom: 16px;
+ padding-left: 36px;
border-radius: 3px;
font-family: Consolas, monaco, monospace;
font-size: 28px;
@@ -376,6 +379,7 @@ func (dt *Flat) HTMLTemplate() string {
{{ range $action := . }}
{{ $action.Instructions }}
{{safe "" }}
{{safe ""}}
- {{ if $action.InviteCode }}
- {{ $action.InviteCode }}
- {{ end }}
{{ if $action.Button.Text }}
{{ $action.Button.Text }}
- {{ end }}
+ {{end}}
+ {{ if $action.InviteCode }}
+ {{ $action.InviteCode }}
+ {{end}}
|
- {{safe ""}}
- {{ end }}
+ {{safe "" }}
+ {{ end }}
{{ end }}
{{ end }}
@@ -433,6 +455,7 @@ func (dt *Flat) HTMLTemplate() string {
{{ range $action := . }}
+ {{if $action.Button.Text}}
{{$.Hermes.Product.TroubleText | replace "{ACTION}" $action.Button.Text}}
@@ -440,6 +463,7 @@ func (dt *Flat) HTMLTemplate() string {
|
{{ end }}
+ {{ end }}
{{ end }}
diff --git a/hermes_test.go b/hermes_test.go
index 303b7a6..6197ce6 100644
--- a/hermes_test.go
+++ b/hermes_test.go
@@ -250,6 +250,44 @@ func (ed *WithSignatureDifferentThanDefault) assertPlainTextContent(t *testing.T
assert.Contains(t, r, "Best regards", "Should have greeting with Dear")
}
+type WithInviteCode struct {
+ theme Theme
+}
+
+func (ed *WithInviteCode) getExample() (Hermes, Email) {
+ h := Hermes{
+ Theme: ed.theme,
+ Product: Product{
+ Name: "Hermes",
+ Link: "http://hermes.com",
+ },
+ DisableCSSInlining: true,
+ }
+
+ email := Email{
+ Body{
+ Name: "Jon Snow",
+ Actions: []Action{
+ {
+ Instructions: "Here is your invite code:",
+ InviteCode: "123456",
+ },
+ },
+ },
+ }
+ return h, email
+}
+
+func (ed *WithInviteCode) assertHTMLContent(t *testing.T, r string) {
+ assert.Contains(t, r, "Here is your invite code", "Should contains the instruction")
+ assert.Contains(t, r, "123456", "Should contain the short code")
+}
+
+func (ed *WithInviteCode) assertPlainTextContent(t *testing.T, r string) {
+ assert.Contains(t, r, "Here is your invite code", "Should contains the instruction")
+ assert.Contains(t, r, "123456", "Should contain the short code")
+}
+
type WithFreeMarkdownContent struct {
theme Theme
}
@@ -380,6 +418,12 @@ func TestThemeWithFreeMarkdownContent(t *testing.T) {
}
}
+func TestThemeWithInviteCode(t *testing.T) {
+ for _, theme := range testedThemes {
+ checkExample(t, &WithInviteCode{theme})
+ }
+}
+
func checkExample(t *testing.T, ex Example) {
// Given an example
h, email := ex.getExample()
| | |