Skip to content

Commit

Permalink
Merge pull request #28 from chasefleming/chasefleming/link
Browse files Browse the repository at this point in the history
Add `Link` element
  • Loading branch information
chasefleming authored Oct 25, 2023
2 parents 4ca8c32 + 8d06e4c commit 2553a2a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
4 changes: 4 additions & 0 deletions elements.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,10 @@ func Img(props Attrs) *Element {

// ========== Meta Elements ==========

func Link(props Attrs) *Element {
return NewElement("link", props)
}

func Meta(props Attrs) *Element {
return NewElement("meta", props)
}
Expand Down
12 changes: 12 additions & 0 deletions elements_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,18 @@ func TestImg(t *testing.T) {

// ========== Meta Elements ==========

func TestLink(t *testing.T) {
expected := `<link href="https://example.com/styles.css" rel="stylesheet">`
el := Link(Attrs{attrs.Rel: "stylesheet", attrs.Href: "https://example.com/styles.css"})
assert.Equal(t, expected, el.Render())
}

func TestMeta(t *testing.T) {
expected := `<meta charset="UTF-8">`
el := Meta(Attrs{attrs.Charset: "UTF-8"})
assert.Equal(t, expected, el.Render())
}

func TestScript(t *testing.T) {
expected := `<script src="https://example.com/script.js"></script>`
el := Script(Attrs{attrs.Src: "https://example.com/script.js"})
Expand Down

0 comments on commit 2553a2a

Please sign in to comment.