From 62b6380847e7c3ffe85737bfdb8a282976f2ac2e Mon Sep 17 00:00:00 2001 From: lemorage Date: Tue, 24 Oct 2023 14:37:00 +0100 Subject: [PATCH] Add library support for more list items --- elements.go | 16 ++++++++++++++++ elements_test.go | 24 ++++++++++++++++++++++++ 2 files changed, 40 insertions(+) diff --git a/elements.go b/elements.go index 9af90ad..25b2884 100644 --- a/elements.go +++ b/elements.go @@ -90,6 +90,22 @@ func Ul(props Attrs, children ...Node) *Element { return NewElement("ul", props, children...) } +func Ol(props Attrs, children ...Node) *Element { + return NewElement("ol", props, children...) +} + +func Dl(props Attrs, children ...Node) *Element { + return NewElement("dl", props, children...) +} + +func Dt(props Attrs, children ...Node) *Element { + return NewElement("dt", props, children...) +} + +func Dd(props Attrs, children ...Node) *Element { + return NewElement("dd", props, children...) +} + // ========== Forms ========== func Button(props Attrs, children ...Node) *Element { diff --git a/elements_test.go b/elements_test.go index c9e39aa..7600e50 100644 --- a/elements_test.go +++ b/elements_test.go @@ -130,6 +130,30 @@ func TestUl(t *testing.T) { assert.Equal(t, expected, el.Render()) } +func TestOl(t *testing.T) { + expected := `
  1. Item 1
  2. Item 2
` + el := Ol(nil, Li(nil, Text("Item 1")), Li(nil, Text("Item 2"))) + assert.Equal(t, expected, el.Render()) +} + +func TestDl(t *testing.T) { + expected := `
Term 1
Description 1
Term 2
Description 2
` + el := Dl(nil, Dt(nil, Text("Term 1")), Dd(nil, Text("Description 1")), Dt(nil, Text("Term 2")), Dd(nil, Text("Description 2"))) + assert.Equal(t, expected, el.Render()) +} + +func TestDt(t *testing.T) { + expected := `
Term 1
` + el := Dt(nil, Text("Term 1")) + assert.Equal(t, expected, el.Render()) +} + +func TestDd(t *testing.T) { + expected := `
Description 1
` + el := Dd(nil, Text("Description 1")) + assert.Equal(t, expected, el.Render()) +} + // ========== Forms ========== func TestButton(t *testing.T) {