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

Commit

Permalink
Merge branch 'development' into helpers
Browse files Browse the repository at this point in the history
  • Loading branch information
markbates authored May 26, 2019
2 parents e657883 + d853e14 commit 0deb001
Show file tree
Hide file tree
Showing 10 changed files with 278 additions and 213 deletions.
2 changes: 0 additions & 2 deletions SHOULDERS.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,6 @@ Thank you to the following **GIANTS**:

* [github.com/gobuffalo/logger](https://godoc.org/github.com/gobuffalo/logger)

* [github.com/gobuffalo/makr](https://godoc.org/github.com/gobuffalo/makr)

* [github.com/gobuffalo/meta](https://godoc.org/github.com/gobuffalo/meta)

* [github.com/gobuffalo/nulls](https://godoc.org/github.com/gobuffalo/nulls)
Expand Down
9 changes: 6 additions & 3 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ jobs:
strategy:
matrix:
go 1.10:
go_version: "1.10.8"
go_version: "1.10"
GO111MODULE: "off"
go 1.11 (on):
go_version: "1.11.5"
GO111MODULE: "on"
Expand All @@ -39,7 +40,8 @@ jobs:
strategy:
matrix:
go 1.10:
go_version: "1.10.8"
go_version: "1.10"
GO111MODULE: "off"
go 1.11 (on):
go_version: "1.11.5"
GO111MODULE: "on"
Expand All @@ -61,7 +63,8 @@ jobs:
strategy:
matrix:
go 1.10:
go_version: "1.10.8"
go_version: "1.10"
GO111MODULE: "off"
go 1.11 (on):
go_version: "1.11.5"
GO111MODULE: "on"
Expand Down
29 changes: 13 additions & 16 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,52 +5,49 @@ require (
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-docker v1.0.7
github.com/gobuffalo/buffalo-plugins v1.14.1
github.com/gobuffalo/buffalo-pop v1.10.0
github.com/gobuffalo/buffalo-pop v1.12.0
github.com/gobuffalo/clara v0.4.1
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.7.0 // indirect
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.1.1
github.com/gobuffalo/helpers v0.0.0-20190425165706-cddb8b03d1d1
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.1.0
github.com/gobuffalo/packr v1.25.0
github.com/gobuffalo/packr/v2 v2.2.0
github.com/gobuffalo/plush v3.8.0+incompatible
github.com/gobuffalo/plush v3.8.2+incompatible
github.com/gobuffalo/plushgen v0.1.0
github.com/gobuffalo/pop v4.10.0+incompatible
github.com/gobuffalo/syncx v0.0.0-20190224160051-33c29581e754
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.2
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-20190426145343-a29dc8fdc734
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-20190430194229-2d28432af7a5
golang.org/x/tools v0.0.0-20190525145741-7be61e1b0e51
gopkg.in/alexcesaro/quotedprintable.v3 v3.0.0-20150716171945-2caba252f4dc
)
131 changes: 109 additions & 22 deletions go.sum

Large diffs are not rendered by default.

46 changes: 26 additions & 20 deletions packrd/packed-packr.go

Large diffs are not rendered by default.

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 0deb001

Please sign in to comment.