diff --git a/components/components.go b/components/components.go index cc565f3..122882f 100644 --- a/components/components.go +++ b/components/components.go @@ -18,12 +18,13 @@ type HTML5Props struct { Language string Head []g.Node Body []g.Node + HTMLAttrs []g.Node } // HTML5 document template. func HTML5(p HTML5Props) g.Node { return Doctype( - HTML(g.If(p.Language != "", Lang(p.Language)), + HTML(g.If(p.Language != "", Lang(p.Language)), g.Group(p.HTMLAttrs), Head( Meta(Charset("utf-8")), Meta(Name("viewport"), Content("width=device-width, initial-scale=1")), diff --git a/components/components_test.go b/components/components_test.go index cfc4116..75e8bb0 100644 --- a/components/components_test.go +++ b/components/components_test.go @@ -30,6 +30,19 @@ func TestHTML5(t *testing.T) { assert.Equal(t, `Hat`, e) }) + + t.Run("returns an html5 document template with additional HTML attributes", func(t *testing.T) { + e := HTML5(HTML5Props{ + Title: "Hat", + Description: "Love hats.", + Language: "en", + Head: []g.Node{Link(Rel("stylesheet"), Href("/hat.css"))}, + Body: []g.Node{Div()}, + HTMLAttrs: []g.Node{Class("h-full"), ID("htmlid")}, + }) + + assert.Equal(t, `Hat
`, e) + }) } func TestClasses(t *testing.T) {