Skip to content

Commit

Permalink
Merge pull request #128 from chasefleming/chasefleming/127
Browse files Browse the repository at this point in the history
Add <base> element
  • Loading branch information
chasefleming authored Mar 3, 2024
2 parents 0e17900 + 4a38349 commit 2f5a0cb
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ Additionally, `None` can be used to create an empty element, as in `elem.Div(nil

`elem` provides utility functions for creating HTML elements:

- **Document Structure**: `Html`, `Head`, `Body`, `Title`, `Link`, `Meta`, `Style`
- **Document Structure**: `Html`, `Head`, `Body`, `Title`, `Link`, `Meta`, `Style`, `Base`
- **Text Content**: `H1`, `H2`, `H3`, `H4`, `H5`, `H6`, `P`, `Blockquote`, `Pre`, `Code`, `I`, `Br`, `Hr`, `Small`, `Q`, `Cite`, `Abbr`, `Data`, `Time`, `Var`, `Samp`, `Kbd`
- **Sectioning & Semantic Layout**: `Article`, `Aside`, `FigCaption`, `Figure`, `Footer`, `Header`, `Hgroup`, `Main`, `Mark`, `Nav`, `Section`
- **Form Elements**: `Form`, `Input`, `Textarea`, `Button`, `Select`, `Optgroup`, `Option`, `Label`, `Fieldset`, `Legend`, `Datalist`, `Meter`, `Output`, `Progress`
Expand Down
7 changes: 6 additions & 1 deletion elements.go
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,12 @@ func Img(attrs attrs.Props) *Element {
return newElement("img", attrs)
}

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

// Base creates a <base> element.
func Base(attrs attrs.Props) *Element {
return newElement("base", attrs)
}

// Link creates a <link> element.
func Link(attrs attrs.Props) *Element {
Expand Down
8 changes: 7 additions & 1 deletion elements_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,13 @@ func TestImg(t *testing.T) {
assert.Equal(t, expected, el.Render())
}

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

func TestBase(t *testing.T) {
expected := `<base href="https://example.com">`
el := Base(attrs.Props{attrs.Href: "https://example.com"})
assert.Equal(t, expected, el.Render())
}

func TestLink(t *testing.T) {
expected := `<link href="https://example.com/styles.css" rel="stylesheet">`
Expand Down

0 comments on commit 2f5a0cb

Please sign in to comment.