diff --git a/render/auto.go b/render/auto.go index b0ce48e89..1bf98ffa8 100644 --- a/render/auto.go +++ b/render/auto.go @@ -91,7 +91,7 @@ func (htmlAutoRenderer) ContentType() string { } func (ir htmlAutoRenderer) Render(w io.Writer, data Data) error { - name := inflect.Name(strings.ToLower(ir.typeName())) + name := inflect.Name(inflect.Underscore(ir.typeName())) name = inflect.Name(name.Singular()) pname := inflect.Name(name.Plural()) diff --git a/render/auto_test.go b/render/auto_test.go index ac6ad9bb8..f4c66fc80 100644 --- a/render/auto_test.go +++ b/render/auto_test.go @@ -94,6 +94,32 @@ func Test_Auto_HTML_List_Plural(t *testing.T) { r.NoError(err) } +func Test_Auto_HTML_List_Plural_MultiWord(t *testing.T) { + r := require.New(t) + + type RoomProvider struct { + Name string + } + + type RoomProviders []RoomProvider + + err := withHTMLFile("room_providers/index.html", "INDEX: <%= len(roomProviders) %>", func(e *render.Engine) { + app := buffalo.New(buffalo.Options{}) + app.GET("/room_providers", func(c buffalo.Context) error { + return c.Render(200, e.Auto(c, RoomProviders{ + RoomProvider{Name: "Ford"}, + RoomProvider{Name: "Chevy"}, + })) + }) + + w := willie.New(app) + res := w.HTML("/room_providers").Get() + + r.Contains(res.Body.String(), "INDEX: 2") + }) + r.NoError(err) +} + func Test_Auto_HTML_Show(t *testing.T) { r := require.New(t)