2019-03-25 02:32:15 +00:00
|
|
|
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)),
|
2019-03-29 03:00:53 +00:00
|
|
|
html5.Div(html5.Disabled(), html5.CustomData("coolness", "awesome"))(),
|
2019-03-25 02:32:15 +00:00
|
|
|
),
|
|
|
|
),
|
|
|
|
)
|
|
|
|
hatmill.WriteDocument(os.Stdout, document)
|
|
|
|
// Output: <!DOCTYPE html><html><head></head><body><div><img src='./me.jpg' id='profile-photo'><script>launchMissiles();</script><div disabled data-coolness='awesome'></div></div></body></html>
|
|
|
|
}
|