Documentation
¶
Overview ¶
Example ¶
package main import ( "os" "gitlab.codemonkeysoftware.net/b/hatmill" ha "gitlab.codemonkeysoftware.net/b/hatmill/attribute" he "gitlab.codemonkeysoftware.net/b/hatmill/element" ) func main() { userInput := "<script>launchMissiles();</script>" document := he.Html()( he.Body()( he.Img(ha.Src("./photo.jpg"), ha.Contenteditable(true)), hatmill.Text(userInput), he.Div(ha.Disabled(true), ha.CustomData("coolness", "awesome"))(), he.Textarea(ha.Rows(25))(), he.Meter(ha.Min(-1.3), ha.Max(5.5e12))(), ), ) hatmill.WriteDocument(os.Stdout, document) }
Output: <!DOCTYPE html><html><body><img src='./photo.jpg' contenteditable='true'><script>launchMissiles();</script><div disabled data-coolness='awesome'></div><textarea rows='25'></textarea><meter min='-1.3' max='5.5E+12'></meter></body></html>
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func WriteDocument ¶
func WriteDocument(w io.Writer, root ParentElement) (n int64, err error)
WriteDocument writes an HTML5 DOCTYPE declaration, followed by root. root should probably be an <html> element.
Types ¶
type Attrib ¶
Attrib represents an HTML attribute.
type ParentElement ¶
type ParentElement struct { VoidElement Children Terms }
ParentElement represents an HTML element that can have children.
type RawText ¶ added in v0.0.4
type RawText string
RawText represents an HTML text node. Unlike Text, its contents are not escaped when written, so it should be used with care. It is intended mainly for use in <style> and <script> elements.
Example ¶
package main import ( "os" "gitlab.codemonkeysoftware.net/b/hatmill" he "gitlab.codemonkeysoftware.net/b/hatmill/element" ) func main() { he.Style()( hatmill.RawText(`div > p::before {content: "Words & stuff: ";}`), ).WriteTo(os.Stdout) }
Output: <style>div > p::before {content: "Words & stuff: ";}</style>
type Term ¶
Term represents a fragment of HTML markup, and is one of VoidElement, ParentElement, Terms, or Text.
type VoidElement ¶
VoidElement represents a void HTML element, that is one that cannot have children.
Click to show internal directories.
Click to hide internal directories.