Skip to content

Commit

Permalink
fixed issue with plush not respecting overriding of it's default helpers
Browse files Browse the repository at this point in the history
  • Loading branch information
markbates committed Jan 19, 2018
1 parent 6d09d49 commit a278059
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
6 changes: 5 additions & 1 deletion context.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,13 +73,17 @@ func NewContext() *Context {
func NewContextWith(data map[string]interface{}) *Context {
c := &Context{
Context: context.Background(),
data: data,
data: map[string]interface{}{},
outer: nil,
moot: &sync.Mutex{},
}
for k, v := range Helpers.helpers {
c.Set(k, v)
}

for k, v := range data {
c.Set(k, v)
}
return c
}

Expand Down
5 changes: 3 additions & 2 deletions helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"sync"

"github.com/gobuffalo/plush/ast"
"github.com/kr/pretty"

"github.com/markbates/inflect"
"github.com/pkg/errors"
Expand Down Expand Up @@ -116,11 +117,11 @@ func lenHelper(v interface{}) int {

// Debug by verbosely printing out using 'pre' tags.
func debugHelper(v interface{}) template.HTML {
return template.HTML(fmt.Sprintf("<pre>%+v</pre>", v))
return template.HTML(fmt.Sprintf("<pre>%s</pre>", inspectHelper(v)))
}

func inspectHelper(v interface{}) string {
return fmt.Sprintf("%+v", v)
return pretty.Sprint(v)
}

func envHelper(k string) string {
Expand Down

0 comments on commit a278059

Please sign in to comment.