Add space before auto-closing element (#20)
Markus Wüstenberg markus@maragu.dk
Thu, 24 Sep 2020 21:55:11 +0200
6 files changed, 30 insertions(+), 30 deletions(-)
M attr/attributes_test.go → attr/attributes_test.go
@@ -32,7 +32,7 @@ }) t.Run("renders as attribute in an element", func(t *testing.T) { e := g.El("div", attr.Classes{"hat": true}) - assert.Equal(t, `<div class="hat"/>`, e) + assert.Equal(t, `<div class="hat" />`, e) }) t.Run("also works with fmt", func(t *testing.T) {
M attr/forms_test.go → attr/forms_test.go
@@ -11,6 +11,6 @@ func TestForms(t *testing.T) { t.Run("adds placeholder and required attributes", func(t *testing.T) { e := g.El("input", attr.Placeholder("hat"), attr.Required()) - assert.Equal(t, `<input placeholder="hat" required/>`, e) + assert.Equal(t, `<input placeholder="hat" required />`, e) }) }
M el/elements_test.go → el/elements_test.go
@@ -10,25 +10,25 @@ ) func TestDocument(t *testing.T) { t.Run("returns doctype and children", func(t *testing.T) { - assert.Equal(t, `<!doctype html><html/>`, el.Document(g.El("html"))) + assert.Equal(t, `<!doctype html><html />`, el.Document(g.El("html"))) }) } func TestHTML(t *testing.T) { t.Run("returns an html element", func(t *testing.T) { - assert.Equal(t, "<html><div/><span/></html>", el.HTML(g.El("div"), g.El("span"))) + assert.Equal(t, "<html><div /><span /></html>", el.HTML(g.El("div"), g.El("span"))) }) } func TestHead(t *testing.T) { t.Run("returns a head element", func(t *testing.T) { - assert.Equal(t, "<head><title/><link/></head>", el.Head(g.El("title"), g.El("link"))) + assert.Equal(t, "<head><title /><link /></head>", el.Head(g.El("title"), g.El("link"))) }) } func TestBody(t *testing.T) { t.Run("returns a body element", func(t *testing.T) { - assert.Equal(t, "<body><div/><span/></body>", el.Body(g.El("div"), g.El("span"))) + assert.Equal(t, "<body><div /><span /></body>", el.Body(g.El("div"), g.El("span"))) }) } @@ -40,25 +40,25 @@ } func TestMeta(t *testing.T) { t.Run("returns a meta element", func(t *testing.T) { - assert.Equal(t, `<meta charset="utf-8"/>`, el.Meta(g.Attr("charset", "utf-8"))) + assert.Equal(t, `<meta charset="utf-8" />`, el.Meta(g.Attr("charset", "utf-8"))) }) } func TestLink(t *testing.T) { t.Run("returns a link element", func(t *testing.T) { - assert.Equal(t, `<link rel="stylesheet"/>`, el.Link(g.Attr("rel", "stylesheet"))) + assert.Equal(t, `<link rel="stylesheet" />`, el.Link(g.Attr("rel", "stylesheet"))) }) } func TestStyle(t *testing.T) { t.Run("returns a style element", func(t *testing.T) { - assert.Equal(t, `<style type="text/css"/>`, el.Style(g.Attr("type", "text/css"))) + assert.Equal(t, `<style type="text/css" />`, el.Style(g.Attr("type", "text/css"))) }) } func TestDiv(t *testing.T) { t.Run("returns a div element", func(t *testing.T) { - assert.Equal(t, `<div><span/></div>`, el.Div(el.Span())) + assert.Equal(t, `<div><span /></div>`, el.Div(el.Span())) }) } @@ -118,13 +118,13 @@ } func TestOl(t *testing.T) { t.Run("returns an ol element", func(t *testing.T) { - assert.Equal(t, `<ol><li/></ol>`, el.Ol(el.Li())) + assert.Equal(t, `<ol><li /></ol>`, el.Ol(el.Li())) }) } func TestUl(t *testing.T) { t.Run("returns a ul element", func(t *testing.T) { - assert.Equal(t, `<ul><li/></ul>`, el.Ul(el.Li())) + assert.Equal(t, `<ul><li /></ul>`, el.Ul(el.Li())) }) } @@ -160,6 +160,6 @@ } func TestImg(t *testing.T) { t.Run("returns an img element with href and alt attributes", func(t *testing.T) { - assert.Equal(t, `<img src="hat.png" alt="hat" id="image"/>`, el.Img("hat.png", "hat", g.Attr("id", "image"))) + assert.Equal(t, `<img src="hat.png" alt="hat" id="image" />`, el.Img("hat.png", "hat", g.Attr("id", "image"))) }) }
M el/forms_test.go → el/forms_test.go
@@ -10,19 +10,19 @@ ) func TestButton(t *testing.T) { t.Run("returns a button element", func(t *testing.T) { - assert.Equal(t, `<button/>`, el.Button()) + assert.Equal(t, `<button />`, el.Button()) }) } func TestForm(t *testing.T) { t.Run("returns a form element with action and method attributes", func(t *testing.T) { - assert.Equal(t, `<form action="/" method="post"/>`, el.Form("/", "post")) + assert.Equal(t, `<form action="/" method="post" />`, el.Form("/", "post")) }) } func TestInput(t *testing.T) { t.Run("returns an input element with attributes type and name", func(t *testing.T) { - assert.Equal(t, `<input type="text" name="hat"/>`, el.Input("text", "hat")) + assert.Equal(t, `<input type="text" name="hat" />`, el.Input("text", "hat")) }) } @@ -40,7 +40,7 @@ } func TestProgress(t *testing.T) { t.Run("returns a progress element with attributes value and max", func(t *testing.T) { - assert.Equal(t, `<progress value="5.5" max="10"/>`, el.Progress(5.5, 10)) + assert.Equal(t, `<progress value="5.5" max="10" />`, el.Progress(5.5, 10)) }) } @@ -53,6 +53,6 @@ } func TestTextarea(t *testing.T) { t.Run("returns a textarea element with attribute name", func(t *testing.T) { - assert.Equal(t, `<textarea name="hat"/>`, el.Textarea("hat")) + assert.Equal(t, `<textarea name="hat" />`, el.Textarea("hat")) }) }
M gomponents.go → gomponents.go
@@ -59,7 +59,7 @@ b.WriteString("<") b.WriteString(name) if len(children) == 0 { - b.WriteString("/>") + b.WriteString(" />") return b.String() } @@ -80,7 +80,7 @@ b.WriteString(inside.String()) if outside.Len() == 0 { - b.WriteString("/>") + b.WriteString(" />") return b.String() }
M gomponents_test.go → gomponents_test.go
@@ -61,22 +61,22 @@ func TestEl(t *testing.T) { t.Run("renders an empty element if no children given", func(t *testing.T) { e := g.El("div") - assert.Equal(t, "<div/>", e) + assert.Equal(t, "<div />", e) }) t.Run("renders an empty element if only attributes given as children", func(t *testing.T) { e := g.El("div", g.Attr("class", "hat")) - assert.Equal(t, `<div class="hat"/>`, e) + assert.Equal(t, `<div class="hat" />`, e) }) t.Run("renders an element, attributes, and element children", func(t *testing.T) { e := g.El("div", g.Attr("class", "hat"), g.El("span")) - assert.Equal(t, `<div class="hat"><span/></div>`, e) + assert.Equal(t, `<div class="hat"><span /></div>`, e) }) t.Run("renders attributes at the correct place regardless of placement in parameter list", func(t *testing.T) { e := g.El("div", g.El("span"), g.Attr("class", "hat")) - assert.Equal(t, `<div class="hat"><span/></div>`, e) + assert.Equal(t, `<div class="hat"><span /></div>`, e) }) t.Run("renders outside if node does not implement placer", func(t *testing.T) { @@ -87,22 +87,22 @@ } func TestText(t *testing.T) { t.Run("renders escaped text", func(t *testing.T) { - e := g.Text("<div/>") - assert.Equal(t, "<div/>", e) + e := g.Text("<div />") + assert.Equal(t, "<div />", e) }) } func TestTextf(t *testing.T) { t.Run("renders interpolated and escaped text", func(t *testing.T) { - e := g.Textf("<%v/>", "div") - assert.Equal(t, "<div/>", e) + e := g.Textf("<%v />", "div") + assert.Equal(t, "<div />", e) }) } func TestRaw(t *testing.T) { t.Run("renders raw text", func(t *testing.T) { - e := g.Raw("<div/>") - assert.Equal(t, "<div/>", e) + e := g.Raw("<div />") + assert.Equal(t, "<div />", e) }) }