27 lines
751 B
Go
27 lines
751 B
Go
|
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'><script>launchMissiles();</script><div disabled data-coolness='awesome'></div></div></body></html>
|
||
|
}
|