diff --git a/layout.go b/layout.go index 4b11aab..ebadd77 100644 --- a/layout.go +++ b/layout.go @@ -42,7 +42,14 @@ type NavItem struct { // username/logout group). type PageHeader struct { Title string - Name string // lowercase product name, e.g. "yasta"; used in and the footer + // AppName is the lowercase product name, e.g. "yasta", used in + // <title> and the footer. Deliberately not "Name" -- a consuming + // project's own per-page data struct commonly embeds both PageHeader + // and a domain type that has its own Name field (e.g. a Kubernetes + // resource's name); two same-depth promoted "Name" fields make + // html/template's ".Name" an ambiguous selector that only fails at + // execution time, not at parse time. + AppName string Lang string // <html lang="...">; "" defaults to "en" Brand string // navbar brand text, e.g. "YASTA" BrandInitial string // single-letter favicon glyph, e.g. "y" diff --git a/layout_test.go b/layout_test.go index 02ba8de..a3a539d 100644 --- a/layout_test.go +++ b/layout_test.go @@ -30,7 +30,7 @@ func TestNewRendererAndPage(t *testing.T) { var buf bytes.Buffer data := PageHeader{ Title: "Dashboard", - Name: "example", + AppName: "example", Brand: "EXAMPLE", BrandInitial: "e", BasePath: "", diff --git a/templates/layout/base.html.tmpl b/templates/layout/base.html.tmpl index 35fedfd..87fa741 100644 --- a/templates/layout/base.html.tmpl +++ b/templates/layout/base.html.tmpl @@ -3,7 +3,7 @@ <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> -<title>{{.Title}}{{if .Name}} · {{.Name}}{{end}} +{{.Title}}{{if .AppName}} · {{.AppName}}{{end}} diff --git a/templates/layout/footer.html.tmpl b/templates/layout/footer.html.tmpl index 1ed89e7..91f8871 100644 --- a/templates/layout/footer.html.tmpl +++ b/templates/layout/footer.html.tmpl @@ -1,3 +1,3 @@ {{define "footer"}} - + {{end}}