Skip to content
This repository has been archived by the owner on Mar 27, 2024. It is now read-only.

removed packr from mailer (fixes #177) #178

Merged
merged 1 commit into from
Jun 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions internal/genny/mail/init/templates/mailers/mailers.go.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ package mailers
import (
"log"

"{{ .opts.App.PackagePkg }}/templates"

"github.com/gobuffalo/buffalo/mail"
"github.com/gobuffalo/buffalo/render"
"github.com/gobuffalo/envy"
"github.com/gobuffalo/packr/v2"
)

var (
Expand All @@ -29,8 +30,8 @@ func init() {
}

r = render.New(render.Options{
HTMLLayout: "layout.html",
TemplatesBox: packr.New("app:mailers:templates", "../templates/mail"),
Helpers: render.Helpers{},
HTMLLayout: "mail/layout.plush.html",
TemplatesFS: templates.FS(),
Helpers: render.Helpers{},
})
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<h1>templates/mailers/layout.plush.html</h1>
<h1>templates/mail/layout.plush.html</h1>

<%= yield %>
6 changes: 3 additions & 3 deletions internal/genny/mail/mail.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ func initGenerator(opts *Options) (*genny.Generator, error) {
const mailerTmpl = `package mailers

import (
"github.com/gobuffalo/buffalo/render"
"github.com/gobuffalo/buffalo/mail"
"github.com/gobuffalo/buffalo/render"
)

func Send{{.opts.Name.Resource}}() error {
Expand All @@ -83,7 +83,7 @@ func Send{{.opts.Name.Resource}}() error {
m.Subject = "{{.opts.Name.Titleize}}"
m.From = ""
m.To = []string{}
err := m.AddBody(r.HTML("{{.opts.Name.File}}.html"), render.Data{})
err := m.AddBody(r.HTML("mail/{{.opts.Name.File}}.html"), render.Data{})
if err != nil {
return err
}
Expand All @@ -93,4 +93,4 @@ func Send{{.opts.Name.Resource}}() error {

const mailTmpl = `<h2>{{.opts.Name.Titleize}}</h2>

<h3>../templates/mail/{{.opts.Name.File}}.plush.html</h3>`
<h3>templates/mail/{{.opts.Name.File}}.plush.html</h3>`
8 changes: 4 additions & 4 deletions internal/genny/mail/mail_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@ func Test_New_NoMailers(t *testing.T) {
f := res.Files[0]
r.Equal("mailers/foo.go", f.Name())
body := f.String()
r.Contains(body, `err := m.AddBody(r.HTML("foo.html"), render.Data{})`)
r.Contains(body, `err := m.AddBody(r.HTML("mail/foo.html"), render.Data{})`)

f = res.Files[1]
r.Equal("mailers/mailers.go", f.Name())

f = res.Files[2]
r.Equal("templates/mail/foo.plush.html", f.Name())
body = f.String()
r.Contains(body, `<h3>../templates/mail/foo.plush.html</h3>`)
r.Contains(body, `<h3>templates/mail/foo.plush.html</h3>`)

f = res.Files[3]
r.Equal("templates/mail/layout.plush.html", f.Name())
Expand All @@ -57,10 +57,10 @@ func Test_New_WithMailers(t *testing.T) {
f := res.Files[0]
r.Equal("mailers/foo.go", f.Name())
body := f.String()
r.Contains(body, `err := m.AddBody(r.HTML("foo.html"), render.Data{})`)
r.Contains(body, `err := m.AddBody(r.HTML("mail/foo.html"), render.Data{})`)

f = res.Files[2]
r.Equal("templates/mail/foo.plush.html", f.Name())
body = f.String()
r.Contains(body, `<h3>../templates/mail/foo.plush.html</h3>`)
r.Contains(body, `<h3>templates/mail/foo.plush.html</h3>`)
}