Skip to content
Permalink
Browse files

Merge and bump BF version

  • Loading branch information...
Depado committed Jun 11, 2018
2 parents 8b61206 + 23ab47d commit 0d886f2878535a0eef0b5f6e452b7f9c741dc20e
Showing with 181 additions and 24 deletions.
  1. +1 −0 .gitignore
  2. +5 −5 .travis.yml
  3. +3 −3 CONTRIBUTING.md
  4. +111 −0 Gopkg.lock
  5. +42 −0 Gopkg.toml
  6. +3 −2 README.md
  7. +3 −3 default.go
  8. +1 −1 examples/default/default.maintenance.txt
  9. +1 −1 examples/flat/flat.maintenance.txt
  10. +1 −1 examples/receipt.go
  11. +2 −2 flat.go
  12. +6 −4 hermes.go
  13. +2 −2 hermes_test.go
@@ -25,3 +25,4 @@ _testmain.go

.DS_Store
coverage.txt
vendor/
@@ -4,17 +4,17 @@ go:
- 1.6
- 1.7
- 1.8
- master
- 1.9

install:
- go get ./...
- go get -t ./...
- curl -L https://github.com/golang/dep/releases/download/v0.3.2/dep-linux-amd64 -o dep
- chmod u+x dep && ./dep ensure
- go get -u github.com/alecthomas/gometalinter
- gometalinter -u -i -f

script:
- go test -race -coverprofile=coverage.txt -covermode=atomic
- gometalinter --config=./gometalinter.json ./...
- gometalinter --vendor --config=./gometalinter.json ./...

after_success:
- bash <(curl -s https://codecov.io/bash)
- bash <(curl -s https://codecov.io/bash)
@@ -45,7 +45,7 @@ func (dt *MyCustomTheme) HTMLTemplate() string {
return "<A go html template with wanted information>"
}
func (dt *Default) PlainTextTemplate() string {
func (dt *MyCustomTheme) PlainTextTemplate() string {
// Get the template from a file (if you want to be able to change the template live without retstarting your application)
// Or write the template by returning pure string here (if you want embbeded template and do not bother with external dependencies)
return "<A go plaintext template with wanter information>"
@@ -188,7 +188,7 @@ The following will inject the table into the e-mail:
{{ with $width }}
width="{{ . }}"
{{ end }}
{{ $align := index .CustomAlignement $entry.Key }}
{{ $align := index .CustomAlignment $entry.Key }}
{{ with $align }}
style="text-align:{{ . }}"
{{ end }}
@@ -203,7 +203,7 @@ The following will inject the table into the e-mail:
{{ range $cell := $row }}
<td
{{ with $columns }}
{{ $align := index .CustomAlignement $cell.Key }}
{{ $align := index .CustomAlignment $cell.Key }}
{{ with $align }}
style="text-align:{{ . }}"
{{ end }}

Some generated files are not rendered by default. Learn more.

@@ -0,0 +1,42 @@

# Gopkg.toml example
#
# Refer to https://github.com/golang/dep/blob/master/docs/Gopkg.toml.md
# for detailed Gopkg.toml documentation.
#
# required = ["github.com/user/thing/cmd/thing"]
# ignored = ["github.com/user/project/pkgX", "bitbucket.org/user/project/pkgA/pkgY"]
#
# [[constraint]]
# name = "github.com/user/project"
# version = "1.0.0"
#
# [[constraint]]
# name = "github.com/user/project2"
# branch = "dev"
# source = "github.com/myfork/project2"
#
# [[override]]
# name = "github.com/x/y"
# version = "2.4.0"


[[constraint]]
name = "github.com/Masterminds/sprig"
version = "2.14.1"

[[constraint]]
name = "github.com/imdario/mergo"
version = "0.2.4"

[[constraint]]
branch = "master"
name = "github.com/jaytaylor/html2text"

[[constraint]]
name = "github.com/stretchr/testify"
version = "1.1.4"

[[constraint]]
name = "gopkg.in/russross/blackfriday.v2"
version = "2.0.0"
@@ -271,7 +271,7 @@ email := hermes.Email{
"Item": "20%",
"Price": "15%",
},
CustomAlignement: map[string]string{
CustomAlignment: map[string]string{
"Price": "right",
},
},
@@ -360,7 +360,7 @@ Hermes - https://example-hermes.com/
Copyright © 2017 Hermes. All rights reserved.
```

Be aware that this content will replace existing tables, dictionnary and actions. Only intros, outros, header and footer will be kept.
Be aware that this content will replace existing tables, dictionary and actions. Only intros, outros, header and footer will be kept.

This is helpful when your application needs sending e-mails, wrote on-the-fly by adminstrators.

@@ -379,3 +379,4 @@ See [CONTRIBUTING.md](CONTRIBUTING.md)
## License

Apache 2.0

@@ -325,7 +325,7 @@ func (dt *Default) HTMLTemplate() string {
{{ with $width }}
width="{{ . }}"
{{ end }}
{{ $align := index .CustomAlignement $entry.Key }}
{{ $align := index .CustomAlignment $entry.Key }}
{{ with $align }}
style="text-align:{{ . }}"
{{ end }}
@@ -340,7 +340,7 @@ func (dt *Default) HTMLTemplate() string {
{{ range $cell := $row }}
<td
{{ with $columns }}
{{ $align := index .CustomAlignement $cell.Key }}
{{ $align := index .CustomAlignment $cell.Key }}
{{ with $align }}
style="text-align:{{ . }}"
{{ end }}
@@ -438,7 +438,7 @@ func (dt *Default) HTMLTemplate() string {

// PlainTextTemplate returns a Golang template that will generate an plain text email.
func (dt *Default) PlainTextTemplate() string {
return `<h2>{{if .Email.Body.Title }}{{ .Email.Body.Title }}{{ else }}{{ .Email.Body.Greeting }} {{ .Email.Body.Name }}{{ end }},</h2>
return `<h2>{{if .Email.Body.Title }}{{ .Email.Body.Title }}{{ else }}{{ .Email.Body.Greeting }} {{ .Email.Body.Name }},{{ end }}</h2>
{{ with .Email.Body.Intros }}
{{ range $line := . }}
<p>{{ $line }}</p>
@@ -20,7 +20,7 @@ Services will be unavailable based on the following schedule:
| Service C | 5AM to 6AM |
+-----------+------------+

Feel free to contact us for any question regarding this matter at support@hermes-example.com ( support@hermes-example.com ) or in our Gitter ( https://gitter.im/ )
Feel free to contact us for any question regarding this matter at support@hermes-example.com or in our Gitter ( https://gitter.im/ )

Yours truly,
Hermes - https://example-hermes.com/
@@ -20,7 +20,7 @@ Services will be unavailable based on the following schedule:
| Service C | 5AM to 6AM |
+-----------+------------+

Feel free to contact us for any question regarding this matter at support@hermes-example.com ( support@hermes-example.com ) or in our Gitter ( https://gitter.im/ )
Feel free to contact us for any question regarding this matter at support@hermes-example.com or in our Gitter ( https://gitter.im/ )

Yours truly,
Hermes - https://example-hermes.com/
@@ -36,7 +36,7 @@ func (r *receipt) Email() hermes.Email {
"Item": "20%",
"Price": "15%",
},
CustomAlignement: map[string]string{
CustomAlignment: map[string]string{
"Price": "right",
},
},
@@ -325,7 +325,7 @@ func (dt *Flat) HTMLTemplate() string {
{{ with $width }}
width="{{ . }}"
{{ end }}
{{ $align := index .CustomAlignement $entry.Key }}
{{ $align := index .CustomAlignment $entry.Key }}
{{ with $align }}
style="text-align:{{ . }}"
{{ end }}
@@ -340,7 +340,7 @@ func (dt *Flat) HTMLTemplate() string {
{{ range $cell := $row }}
<td
{{ with $columns }}
{{ $align := index .CustomAlignement $cell.Key }}
{{ $align := index .CustomAlignment $cell.Key }}
{{ with $align }}
style="text-align:{{ . }}"
{{ end }}
@@ -4,10 +4,12 @@ import (
"bytes"
"html/template"

"html/template"

"github.com/Masterminds/sprig"
"github.com/imdario/mergo"
"github.com/jaytaylor/html2text"
"github.com/russross/blackfriday"
"gopkg.in/russross/blackfriday.v2"
)

// Hermes is an instance of the hermes email generator
@@ -74,7 +76,7 @@ type Body struct {

// ToHTML converts Markdown to HTML
func (c Markdown) ToHTML() template.HTML {
return template.HTML(blackfriday.MarkdownCommon([]byte(string(c))))
return template.HTML(blackfriday.Run([]byte(string(c))))
}

// Entry is a simple entry of a map
@@ -93,8 +95,8 @@ type Table struct {

// Columns contains meta-data for the different columns
type Columns struct {
CustomWidth map[string]string
CustomAlignement map[string]string
CustomWidth map[string]string
CustomAlignment map[string]string
}

// Action is an action the user can do on the email (click on a button)
@@ -75,7 +75,7 @@ func (ed *SimpleExample) getExample() (Hermes, Email) {
"Item": "20%",
"Price": "15%",
},
CustomAlignement: map[string]string{
CustomAlignment: map[string]string{
"Price": "right",
},
},
@@ -459,7 +459,7 @@ func TestHermes_Default(t *testing.T) {
assert.Empty(t, email.Body.Outros)
assert.Empty(t, email.Body.Table.Data)
assert.Empty(t, email.Body.Table.Columns.CustomWidth)
assert.Empty(t, email.Body.Table.Columns.CustomAlignement)
assert.Empty(t, email.Body.Table.Columns.CustomAlignment)
assert.Empty(t, string(email.Body.FreeMarkdown))

assert.Equal(t, email.Body.Greeting, "Hi")

0 comments on commit 0d886f2

Please sign in to comment.
You can’t perform that action at this time.