2017-03-26 17:11:30 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2017-03-28 16:16:20 +00:00
|
|
|
"fmt"
|
2017-03-26 17:11:30 +00:00
|
|
|
"github.com/matcornic/hermes"
|
|
|
|
"io/ioutil"
|
|
|
|
)
|
|
|
|
|
2017-03-28 16:16:20 +00:00
|
|
|
type Example interface {
|
|
|
|
Email() hermes.Email
|
|
|
|
Name() string
|
|
|
|
}
|
|
|
|
|
2017-03-26 17:11:30 +00:00
|
|
|
func main() {
|
|
|
|
h := hermes.Hermes{
|
|
|
|
Product: hermes.Product{
|
|
|
|
Name: "Hermes",
|
2017-03-28 16:16:20 +00:00
|
|
|
Link: "https://example-hermes.com/",
|
|
|
|
Logo: "http://www.duchess-france.org/wp-content/uploads/2016/01/gopher.png",
|
2017-03-26 17:11:30 +00:00
|
|
|
},
|
|
|
|
}
|
|
|
|
|
2017-03-28 16:16:20 +00:00
|
|
|
examples := []Example{
|
|
|
|
new(Welcome),
|
|
|
|
new(Reset),
|
|
|
|
new(Receipt),
|
2017-03-26 17:11:30 +00:00
|
|
|
}
|
|
|
|
|
2017-03-28 16:16:20 +00:00
|
|
|
for _, e := range examples {
|
|
|
|
generateEmails(h, e.Email(), e.Name())
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
func generateEmails(h hermes.Hermes, email hermes.Email, example string) {
|
|
|
|
// Generate the HTML template and save it
|
|
|
|
res, err := h.GenerateHTML(email)
|
2017-03-26 17:11:30 +00:00
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
2017-03-28 16:16:20 +00:00
|
|
|
err = ioutil.WriteFile(fmt.Sprintf("%v.%v.html", h.Theme.Name(), example), []byte(res), 0644)
|
2017-03-26 17:11:30 +00:00
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
|
2017-03-28 16:16:20 +00:00
|
|
|
// Generate the plaintext template and save it
|
|
|
|
res, err = h.GeneratePlainText(email)
|
2017-03-26 17:11:30 +00:00
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
2017-03-28 16:16:20 +00:00
|
|
|
err = ioutil.WriteFile(fmt.Sprintf("%v.%v.txt", h.Theme.Name(), example), []byte(res), 0644)
|
2017-03-26 17:11:30 +00:00
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
}
|