all repos — gomponents @ ec86ca5c71fecf21590b872737fbadd9aa3e158b

HTML components in pure Go

Add video element and related attributes (#84) Adds the `video` element and `loop`, `muted`, `playsinline`, `poster` attributes.

Markus Wüstenberg
commit

ec86ca5c71fecf21590b872737fbadd9aa3e158b

parent

0efc71d6f326efc88d25688f50f83b948b40fc38

4 files changed, 40 insertions(+), 15 deletions(-)

changed files
M html/attributes.gohtml/attributes.go
@@ -28,8 +28,20 @@ func Disabled() g.Node {
return g.Attr("disabled") } +func Loop() g.Node { + return g.Attr("loop") +} + func Multiple() g.Node { return g.Attr("multiple") +} + +func Muted() g.Node { + return g.Attr("muted") +} + +func PlaysInline() g.Node { + return g.Attr("playsinline") } func ReadOnly() g.Node {
@@ -142,12 +154,16 @@ func Pattern(v string) g.Node {
return g.Attr("pattern", v) } -func Preload(v string) g.Node { - return g.Attr("preload", v) -} - func Placeholder(v string) g.Node { return g.Attr("placeholder", v) +} + +func Poster(v string) g.Node { + return g.Attr("poster", v) +} + +func Preload(v string) g.Node { + return g.Attr("preload", v) } func Rel(v string) g.Node {
M html/attributes_test.gohtml/attributes_test.go
@@ -11,16 +11,19 @@ )
func TestBooleanAttributes(t *testing.T) { cases := map[string]func() g.Node{ - "async": Async, - "autofocus": AutoFocus, - "autoplay": AutoPlay, - "controls": Controls, - "defer": Defer, - "disabled": Disabled, - "multiple": Multiple, - "readonly": ReadOnly, - "required": Required, - "selected": Selected, + "async": Async, + "autofocus": AutoFocus, + "autoplay": AutoPlay, + "controls": Controls, + "defer": Defer, + "disabled": Disabled, + "loop": Loop, + "multiple": Multiple, + "muted": Muted, + "playsinline": PlaysInline, + "readonly": ReadOnly, + "required": Required, + "selected": Selected, } for name, fn := range cases {
@@ -55,8 +58,9 @@ "min": Min,
"minlength": MinLength, "name": Name, "pattern": Pattern, + "placeholder": Placeholder, + "poster": Poster, "preload": Preload, - "placeholder": Placeholder, "rel": Rel, "role": Role, "rows": Rows,
M html/elements.gohtml/elements.go
@@ -426,3 +426,7 @@
func Var(children ...g.Node) g.Node { return g.El("var", g.Group(children)) } + +func Video(children ...g.Node) g.Node { + return g.El("video", g.Group(children)) +}
M html/elements_test.gohtml/elements_test.go
@@ -118,6 +118,7 @@ "tr": Tr,
"u": U, "ul": Ul, "var": Var, + "video": Video, } for name, fn := range cases {