all repos — gomponents @ 7c0f2e4cbb4da6d7074bd78be9c55d3495c0dad7

HTML components in pure Go

Add LinkStylesheet and LinkPreload components (#79) These are often used in the `<head>` part of the HTML.

Markus Wüstenberg
commit

7c0f2e4cbb4da6d7074bd78be9c55d3495c0dad7

parent

3e9e00ca0dc6b58e58694d84c97a1d2f2ab4002b

1 file changed, 14 insertions(+), 0 deletions(-)

changed files
M components/elements_test.gocomponents/elements_test.go
@@ -14,3 +14,17 @@ n := c.InputHidden("id", "partyhat", g.Attr("class", "hat"))
assert.Equal(t, `<input type="hidden" name="id" value="partyhat" class="hat">`, n) }) } + +func TestLinkStylesheet(t *testing.T) { + t.Run("returns a link element with rel stylesheet and the given href", func(t *testing.T) { + n := c.LinkStylesheet("style.css", g.Attr("media", "print")) + assert.Equal(t, `<link rel="stylesheet" href="style.css" media="print">`, n) + }) +} + +func TestLinkPreload(t *testing.T) { + t.Run("returns a link element with rel preload and the given href and as", func(t *testing.T) { + n := c.LinkPreload("party.woff2", "font", g.Attr("type", "font/woff2")) + assert.Equal(t, `<link rel="preload" href="party.woff2" as="font" type="font/woff2">`, n) + }) +}