diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 81e1d47..66b66e3 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -276,15 +276,15 @@ The following will inject the action link (or button) into the e-mail: {{ end }} ``` -A good practice is to describe action in footer in case of problem when displaying button and CSS +A good practice is to describe action in footer in case of problem when displaying button and CSS. The text for the description is provided through the `TroubleText` field of the `Product` struct. The text may contain a placeholder `{ACTION}` which is expected to be replaced with the text of the button. The default value of `TroubleText` is `If you’re having trouble with the button '{ACTION}', copy and paste the URL below into your web browser.` ```html -{{ with .Email.Body.Actions }} +{{ with .Email.Body.Actions }}
- If you’re having trouble with the button '{{ $action.Button.Text }}', copy and paste the URL below into your web browser. +{{$.Hermes.Product.TroubleText | replace "{ACTION}" $action.Button.Text}} |
{{ end }}
diff --git a/README.md b/README.md
index 5742bba..79d0acd 100644
--- a/README.md
+++ b/README.md
@@ -157,7 +157,7 @@ To customize the `Copyright`, override it when initializing `Hermes` within your
// Configure hermes by setting a theme and your product info
h := hermes.Hermes{
// Optional Theme
- // Theme: new(Default)
+ // Theme: new(Default)
Product: hermes.Product{
// Appears in header & footer of e-mails
Name: "Hermes",
@@ -168,6 +168,20 @@ h := hermes.Hermes{
}
```
+To use a custom fallback text at the end of the email, change the `TroubleText` field of the `hermes.Product` struct. The default value is `If you’re having trouble with the button '{ACTION}', copy and paste the URL below into your web browser.`. The `{ACTION}` placeholder will be replaced with the corresponding text of the supplied action button:
+
+```go
+// Configure hermes by setting a theme and your product info
+h := hermes.Hermes{
+ // Optional Theme
+ // Theme: new(Default)
+ Product: hermes.Product{
+ // Custom trouble text
+ TroubleText: "If the {ACTION}-button is not working for you, just copy and paste the URL below into your web browser."
+ },
+}
+```
+
## Elements
Hermes supports injecting custom elements such as dictionaries, tables and action buttons into e-mails.
diff --git a/default.go b/default.go
index 19d5f83..c632288 100644
--- a/default.go
+++ b/default.go
@@ -346,7 +346,7 @@ func (dt *Default) HTMLTemplate() string {
{{ range $action := . }}
- If you’re having trouble with the button '{{ $action.Button.Text }}', copy and paste the URL below into your web browser. +{{$.Hermes.Product.TroubleText | replace "{ACTION}" $action.Button.Text}} |