From c6c5fbd0f92667d9a98a232b455ea26180017e4d Mon Sep 17 00:00:00 2001 From: Hans Raaf Date: Fri, 23 Oct 2020 14:12:47 +0200 Subject: Add br and hr element helpers (#30) --- el/content.go | 8 ++++++++ el/content_test.go | 12 ++++++++++++ 2 files changed, 20 insertions(+) (limited to 'el') diff --git a/el/content.go b/el/content.go index 5a4bce9..a4bcd61 100644 --- a/el/content.go +++ b/el/content.go @@ -23,3 +23,11 @@ func Li(children ...g.Node) g.NodeFunc { func P(children ...g.Node) g.NodeFunc { return g.El("p", children...) } + +func Br(children ...g.Node) g.NodeFunc { + return g.El("br", children...) +} + +func Hr(children ...g.Node) g.NodeFunc { + return g.El("hr", children...) +} diff --git a/el/content_test.go b/el/content_test.go index b31ad2d..9cb1d52 100644 --- a/el/content_test.go +++ b/el/content_test.go @@ -37,3 +37,15 @@ func TestP(t *testing.T) { assert.Equal(t, `

hat

`, el.P(g.Text("hat"))) }) } + +func TestBr(t *testing.T) { + t.Run("returns a br element in context", func(t *testing.T) { + assert.Equal(t, `

Test
Me

`, el.P(g.Text("Test"), el.Br(), g.Text("Me"))) + }) +} + +func TestHr(t *testing.T) { + t.Run("returns a hr element with class", func(t *testing.T) { + assert.Equal(t, `
`, el.Hr(g.Attr("class", "test"))) + }) +} -- cgit 1.4.1