about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--el/content.go8
-rw-r--r--el/content_test.go12
-rw-r--r--examples/simple/simple.go1
3 files changed, 21 insertions, 0 deletions
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, `<p>hat</p>`, 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, `<p>Test<br />Me</p>`, 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, `<hr class="test" />`, el.Hr(g.Attr("class", "test")))
+	})
+}
diff --git a/examples/simple/simple.go b/examples/simple/simple.go
index 92bc8cc..56747e4 100644
--- a/examples/simple/simple.go
+++ b/examples/simple/simple.go
@@ -44,6 +44,7 @@ func page(props pageProps) g.Node {
 			),
 			el.Body(
 				navbar(navbarProps{path: props.path}),
+				el.Hr(),
 				el.H1(props.title),
 				el.P(g.Text(fmt.Sprintf("Welcome to the page at %v.", props.path))),
 				el.P(g.Text(fmt.Sprintf("Rendered at %v", time.Now()))),