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

Commit

Permalink
Merge branch 'master' into development
Browse files Browse the repository at this point in the history
  • Loading branch information
markbates committed May 26, 2019
2 parents 461ecfc + c6fe8f3 commit ee4089b
Show file tree
Hide file tree
Showing 9 changed files with 291 additions and 204 deletions.
3 changes: 3 additions & 0 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ jobs:
matrix:
go 1.10:
go_version: "1.10"
GO111MODULE: "off"
go 1.11 (on):
go_version: "1.11.5"
GO111MODULE: "on"
Expand All @@ -40,6 +41,7 @@ jobs:
matrix:
go 1.10:
go_version: "1.10"
GO111MODULE: "off"
go 1.11 (on):
go_version: "1.11.5"
GO111MODULE: "on"
Expand All @@ -62,6 +64,7 @@ jobs:
matrix:
go 1.10:
go_version: "1.10"
GO111MODULE: "off"
go 1.11 (on):
go_version: "1.11.5"
GO111MODULE: "on"
Expand Down
48 changes: 24 additions & 24 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,54 +1,54 @@
module github.com/gobuffalo/buffalo

require (
cloud.google.com/go v0.36.0 // indirect
github.com/BurntSushi/toml v0.3.1
github.com/dustin/go-humanize v1.0.0
github.com/fatih/color v1.7.0
github.com/gobuffalo/attrs v0.0.0-20190224210810-a9411de4debd
github.com/gobuffalo/buffalo-docker v1.0.6
github.com/gobuffalo/buffalo-plugins v1.14.0
github.com/gobuffalo/buffalo-pop v1.10.0
github.com/gobuffalo/buffalo-docker v1.0.7
github.com/gobuffalo/buffalo-plugins v1.14.1
github.com/gobuffalo/buffalo-pop v1.12.0
github.com/gobuffalo/clara v0.4.1
github.com/gobuffalo/depgen v0.0.0-20190329151759-d478694a28d3
github.com/gobuffalo/depgen v0.1.1
github.com/gobuffalo/envy v1.7.0
github.com/gobuffalo/events v1.3.1
github.com/gobuffalo/fizz v1.6.1 // indirect
github.com/gobuffalo/flect v0.1.1
github.com/gobuffalo/genny v0.0.0-20190403191548-3ca520ef0d9e
github.com/gobuffalo/fizz v1.8.0 // indirect
github.com/gobuffalo/flect v0.1.3
github.com/gobuffalo/genny v0.1.1
github.com/gobuffalo/github_flavored_markdown v1.0.7
github.com/gobuffalo/gogen v0.0.0-20190315121717-8f38393713f5
github.com/gobuffalo/gogen v0.1.1
github.com/gobuffalo/httptest v1.2.0
github.com/gobuffalo/logger v0.0.0-20190315122211-86e12af44bc2
github.com/gobuffalo/makr v1.1.5 // indirect
github.com/gobuffalo/meta v0.0.0-20190329152330-e161e8a93e3b
github.com/gobuffalo/nulls v0.0.0-20190305142546-85f3c9250d87
github.com/gobuffalo/packd v0.0.0-20190315124812-a385830c7fc0
github.com/gobuffalo/packr v1.24.1
github.com/gobuffalo/packd v0.1.0
github.com/gobuffalo/packr v1.25.0
github.com/gobuffalo/packr/v2 v2.2.0
github.com/gobuffalo/plush v3.7.34+incompatible
github.com/gobuffalo/plushgen v0.0.0-20190329152458-0555238fe0d9
github.com/gobuffalo/pop v4.10.0+incompatible
github.com/gobuffalo/tags v2.0.16+incompatible
github.com/gobuffalo/plush v3.8.2+incompatible
github.com/gobuffalo/plushgen v0.1.0
github.com/gobuffalo/pop v4.11.0+incompatible
github.com/gobuffalo/tags v2.1.0+incompatible
github.com/gobuffalo/x v0.0.0-20190224155809-6bb134105960
github.com/gorilla/context v1.1.1
github.com/gorilla/mux v1.7.1
github.com/gorilla/mux v1.7.2
github.com/gorilla/sessions v1.1.3
github.com/karrick/godirwalk v1.8.0
github.com/karrick/godirwalk v1.10.3
github.com/markbates/deplist v1.1.3
github.com/markbates/grift v1.0.5
github.com/markbates/grift v1.0.6
github.com/markbates/oncer v0.0.0-20181203154359-bf2de49a0be2
github.com/markbates/refresh v1.7.1
github.com/markbates/safe v1.0.1
github.com/markbates/sigtx v1.0.0
github.com/monoculum/formam v0.0.0-20190307031628-bc555adff0cd
github.com/pkg/errors v0.8.1
github.com/sirupsen/logrus v1.4.1
github.com/spf13/cobra v0.0.3
github.com/sirupsen/logrus v1.4.2
github.com/spf13/cobra v0.0.4
github.com/spf13/pflag v1.0.3
github.com/spf13/viper v1.3.2
github.com/spf13/viper v1.4.0
github.com/stretchr/testify v1.3.0
golang.org/x/crypto v0.0.0-20190404164418-38d8ce5564a5
golang.org/x/sync v0.0.0-20190412183630-56d357773e84
golang.org/x/tools v0.0.0-20190416151739-9c9e1878f421
golang.org/x/crypto v0.0.0-20190513172903-22d7a77e9e5f
golang.org/x/sync v0.0.0-20190423024810-112230192c58
golang.org/x/tools v0.0.0-20190525145741-7be61e1b0e51
gopkg.in/alexcesaro/quotedprintable.v3 v3.0.0-20150716171945-2caba252f4dc
)
164 changes: 134 additions & 30 deletions go.sum

Large diffs are not rendered by default.

8 changes: 7 additions & 1 deletion packrd/packed-packr.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

47 changes: 19 additions & 28 deletions render/js_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"strings"
"testing"

"github.com/gobuffalo/packd"
"github.com/gobuffalo/packr/v2"
"github.com/stretchr/testify/require"
)
Expand Down Expand Up @@ -119,48 +120,38 @@ func Test_JavaScript_JS_Partial_Without_Extension(t *testing.T) {

const testJS = "let a = 1;\n<%= partial(\"part\") %>"
const partJS = "alert('Hi <%= name %>!');"
box := packd.NewMemoryBox()

err := withHTMLFile("test.js", testJS, func(e *Engine) {
err := withHTMLFile("_part.js", partJS, func(e *Engine) {
bb := &bytes.Buffer{}
renderer := e.JavaScript("test.js")
r.Equal("application/javascript", renderer.ContentType())
err := renderer.Render(bb, Data{"name": "Yonghwan"})
r.NoError(err)
r.Equal("let a = 1;\nalert('Hi Yonghwan!');", bb.String())
})
r.NoError(err)
r.NoError(box.AddString("_part.js", partJS))
r.NoError(box.AddString("test.js", testJS))

re := New(Options{
TemplatesBox: box,
})

bb := &bytes.Buffer{}

err := re.JavaScript("test.js").Render(bb, Data{"name": "Yonghwan"})
r.NoError(err)
r.Equal("let a = 1;\nalert('Hi Yonghwan!');", bb.String())
}

func Test_JavaScript_HTML_Partial(t *testing.T) {
r := require.New(t)

dir, err := ioutil.TempDir("", "")
r.NoError(err)
defer os.RemoveAll(dir)

re := New(Options{
TemplatesBox: packr.New(dir, dir),
})

pf, err := os.Create(filepath.Join(dir, "_part.html"))
r.NoError(err)

const h = `<div id="foo">
<p>hi</p>
</div>`
_, err = pf.WriteString(h)
r.NoError(err)
box := packd.NewMemoryBox()
r.NoError(box.AddString("_part.html", h))
r.NoError(box.AddString("test.js", "let a = \"<%= partial(\"part.html\") %>\""))

tf, err := os.Create(filepath.Join(dir, "test.js"))
r.NoError(err)
_, err = tf.WriteString("let a = \"<%= partial(\"part.html\") %>\"")
r.NoError(err)
re := New(Options{
TemplatesBox: box,
})

bb := &bytes.Buffer{}
err = re.JavaScript("test.js").Render(bb, map[string]interface{}{})
err := re.JavaScript("test.js").Render(bb, map[string]interface{}{})
r.NoError(err)

r.Equal("let a = \"\\x3Cdiv id=\\\"foo\\\"\\x3E\\u000A\\u0009\\x3Cp\\x3Ehi\\x3C/p\\x3E\\u000A\\x3C/div\\x3E\"", bb.String())
Expand Down
Loading

0 comments on commit ee4089b

Please sign in to comment.