From 5d2f0f1b87aff69edf5b3a993afbb1ae2db946d0 Mon Sep 17 00:00:00 2001 From: Markus Wüstenberg Date: Wed, 28 Apr 2021 10:42:49 +0200 Subject: Use g.If in HTML5 helper (#65) Inlining looks much nicer.--- components/documents.go | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) (limited to 'components') diff --git a/components/documents.go b/components/documents.go index 47373cc..b9ab085 100644 --- a/components/documents.go +++ b/components/documents.go @@ -18,20 +18,13 @@ type HTML5Props struct { // HTML5 document template. func HTML5(p HTML5Props) g.Node { - var lang, description g.Node - if p.Language != "" { - lang = Lang(p.Language) - } - if p.Description != "" { - description = Meta(Name("description"), Content(p.Description)) - } return Doctype( - HTML(lang, + HTML(g.If(p.Language != "", Lang(p.Language)), Head( Meta(Charset("utf-8")), Meta(Name("viewport"), Content("width=device-width, initial-scale=1")), TitleEl(p.Title), - description, + g.If(p.Description != "", Meta(Name("description"), Content(p.Description))), g.Group(p.Head), ), Body(g.Group(p.Body)), -- cgit 1.4.1