Skip to content

Commit

Permalink
Possibility to customise 'Action Trouble Text'
Browse files Browse the repository at this point in the history
  • Loading branch information
fridolin-koch committed May 13, 2017
1 parent 8fb17c0 commit 44be377
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
2 changes: 1 addition & 1 deletion default.go
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ func (dt *Default) HTMLTemplate() string {
{{ range $action := . }}
<tr>
<td>
<p class="sub">If you’re having trouble with the button '{{ $action.Button.Text }}', copy and paste the URL below into your web browser.</p>
<p class="sub">{{printf $.Hermes.Product.TroubleText $action.Button.Text}}</p>
<p class="sub"><a href="{{ $action.Button.Link }}">{{ $action.Button.Link }}</a></p>
</td>
</tr>
Expand Down
14 changes: 8 additions & 6 deletions hermes.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,11 @@ const TDRightToLeft TextDirection = "rtl"
// Product represents your company product (brand)
// Appears in header & footer of e-mails
type Product struct {
Name string
Link string // e.g. https://matcornic.github.io
Logo string // e.g. https://matcornic.github.io/img/logo.png
Copyright string // Copyright © 2017 Hermes. All rights reserved.
Name string
Link string // e.g. https://matcornic.github.io
Logo string // e.g. https://matcornic.github.io/img/logo.png
Copyright string // Copyright © 2017 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 %s, copy and paste the URL below into your web browser.`)
}

// Email is the email containing a body
Expand Down Expand Up @@ -120,8 +121,9 @@ func setDefaultHermesValues(h *Hermes) error {
Theme: new(Default),
TextDirection: defaultTextDirection,
Product: Product{
Name: "Hermes",
Copyright: "Copyright © 2017 Hermes. All rights reserved.",
Name: "Hermes",
Copyright: "Copyright © 2017 Hermes. All rights reserved.",
TroubleText: "If you’re having trouble with the button '%s', copy and paste the URL below into your web browser.",
},
}
// Merge the given hermes engine configuration with default one
Expand Down
2 changes: 1 addition & 1 deletion hermes_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ func (ed *SimpleExample) assertHTMLContent(t *testing.T, r string) {
assert.Contains(t, r, "http://hermes-link.com", "Product: Should find the link of the product in email")
assert.Contains(t, r, "Copyright © Hermes-Test", "Product: Should find the Copyright of the product in email")
assert.Contains(t, r, "http://www.duchess-france.org/wp-content/uploads/2016/01/gopher.png", "Product: Should find the logo of the product in email")

assert.Contains(t, r, "If you’re having trouble with the button &#39;Confirm your account&#39;, copy and paste the URL below into your web browser.", "Product: Should find the trouble text in email")
// Assert on email body
assert.Contains(t, r, "Hi Jon Snow", "Name: Should find the name of the person")
assert.Contains(t, r, "Welcome to Hermes", "Intro: Should have intro")
Expand Down

0 comments on commit 44be377

Please sign in to comment.