diff options
author | Markus Wüstenberg | 2020-12-10 13:00:23 +0100 |
---|---|---|
committer | GitHub | 2020-12-10 13:00:23 +0100 |
commit | a76262652b227c95ce140f3698c46f59b79354ac (patch) | |
tree | 15987ad4a4a4f830f0df9fc110faf667fe83514a /components/documents.go | |
parent | a7e24c6cddaafb98091c3989c9da7779eeba30b5 (diff) | |
download | gomponents-a76262652b227c95ce140f3698c46f59b79354ac.tar.lz gomponents-a76262652b227c95ce140f3698c46f59b79354ac.tar.zst gomponents-a76262652b227c95ce140f3698c46f59b79354ac.zip |
Move elements and attributes into html package (#52)
This makes it easier to use dot-imports. Also updated the readme and examples with new usage, and move the `Classes` helper into the `components` package.
Diffstat (limited to 'components/documents.go')
-rw-r--r-- | components/documents.go | 29 |
1 files changed, 14 insertions, 15 deletions
diff --git a/components/documents.go b/components/documents.go index 5e96466..e2d3a22 100644 --- a/components/documents.go +++ b/components/documents.go @@ -1,15 +1,14 @@ -// Package components provides high-level components that are composed of low-level elements and attributes. +// Package components provides high-level components and helpers that are composed of low-level elements and attributes. package components import ( g "github.com/maragudk/gomponents" - "github.com/maragudk/gomponents/attr" - "github.com/maragudk/gomponents/el" + . "github.com/maragudk/gomponents/html" ) -// DocumentProps for HTML5. +// HTML5Props for HTML5. // Title is set no matter what, Description and Language elements only if the strings are non-empty. -type DocumentProps struct { +type HTML5Props struct { Title string Description string Language string @@ -18,24 +17,24 @@ type DocumentProps struct { } // HTML5 document template. -func HTML5(p DocumentProps) g.NodeFunc { +func HTML5(p HTML5Props) g.NodeFunc { var lang, description g.Node if p.Language != "" { - lang = attr.Lang(p.Language) + lang = Lang(p.Language) } if p.Description != "" { - description = el.Meta(attr.Name("description"), attr.Content(p.Description)) + description = Meta(Name("description"), Content(p.Description)) } - return el.Document( - el.HTML(lang, - el.Head( - el.Meta(attr.Charset("utf-8")), - el.Meta(attr.Name("viewport"), attr.Content("width=device-width, initial-scale=1")), - el.Title(p.Title), + return Document( + HTML(lang, + Head( + Meta(Charset("utf-8")), + Meta(Name("viewport"), Content("width=device-width, initial-scale=1")), + TitleEl(p.Title), description, g.Group(p.Head), ), - el.Body(g.Group(p.Body)), + Body(g.Group(p.Body)), ), ) } |