diff --git a/style_test.go b/style_test.go index 08d70a4..911d71c 100644 --- a/style_test.go +++ b/style_test.go @@ -103,3 +103,19 @@ func TestSidebarGroupsAndIcons(t *testing.T) { } } } + +// A page without NavItems (a login page) renders no sidebar container: +// the modern style draws it as a card, which would show up empty. +func TestSidebarWithoutItems(t *testing.T) { + r, err := NewRenderer(testPagesFS(), "pages", []string{"dashboard"}, ".html.tmpl", testFuncs()) + if err != nil { + t.Fatalf("NewRenderer: %v", err) + } + var buf bytes.Buffer + if err := r.Page(&buf, "dashboard", PageHeader{Title: "Log in"}); err != nil { + t.Fatal(err) + } + if strings.Contains(buf.String(), `class="nav flex-column`) { + t.Errorf("empty sidebar container rendered\n---\n%s", buf.String()) + } +} diff --git a/templates/layout/sidebar.html.tmpl b/templates/layout/sidebar.html.tmpl index 5f1f3c4..dac4fd6 100644 --- a/templates/layout/sidebar.html.tmpl +++ b/templates/layout/sidebar.html.tmpl @@ -1,7 +1,7 @@ {{define "sidebar"}} -{{end}} {{end}}