Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Link element #28

Merged
merged 1 commit into from
Oct 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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