hatmill/html5/html5_test.go

27 lines
751 B
Go
Raw Normal View History

package html5_test
import (
"gitlab.codemonkeysoftware.net/b/hatmill"
html5 "gitlab.codemonkeysoftware.net/b/hatmill/html5"
"html"
"os"
)
func Example() {
userInput := "<script>launchMissiles();</script>"
document := html5.Html()(
html5.Head()(),
html5.Body()(
html5.Div()(
html5.Img(html5.Src("./me.jpg"), html5.Id("profile-photo")),
html5.Text(html.EscapeString(userInput)),
html5.Div(html5.Disabled(), html5.Data("coolness", "awesome"))(),
),
),
)
hatmill.WriteDocument(os.Stdout, document)
// Output: <!DOCTYPE html><html><head></head><body><div><img src='./me.jpg' id='profile-photo'>&lt;script&gt;launchMissiles();&lt;/script&gt;<div disabled data-coolness='awesome'></div></div></body></html>
}