Added all non-obsolete, non-experimental attribs from MDN

This commit is contained in:
Brandon Dyck 2019-04-08 21:52:26 -06:00
parent e43b8aa6ee
commit f637b196fe
6 changed files with 975 additions and 6 deletions

View File

@ -5,6 +5,255 @@ package attribute
import "gitlab.codemonkeysoftware.net/b/hatmill" import "gitlab.codemonkeysoftware.net/b/hatmill"
// Accept creates a "accept" attribute
func Accept(value string) hatmill.Attrib {
return hatmill.Attrib{
Key: "accept",
Value: value,
}
}
// AcceptCharset creates a "accept-charset" attribute
func AcceptCharset(value string) hatmill.Attrib {
return hatmill.Attrib{
Key: "accept-charset",
Value: value,
}
}
// Accesskey creates a "accesskey" attribute
func Accesskey(value string) hatmill.Attrib {
return hatmill.Attrib{
Key: "accesskey",
Value: value,
}
}
// Action creates a "action" attribute
func Action(value string) hatmill.Attrib {
return hatmill.Attrib{
Key: "action",
Value: value,
}
}
// Align creates a "align" attribute
func Align(value string) hatmill.Attrib {
return hatmill.Attrib{
Key: "align",
Value: value,
}
}
// Allow creates a "allow" attribute
func Allow(value string) hatmill.Attrib {
return hatmill.Attrib{
Key: "allow",
Value: value,
}
}
// Alt creates a "alt" attribute
func Alt(value string) hatmill.Attrib {
return hatmill.Attrib{
Key: "alt",
Value: value,
}
}
// Async creates a "async" attribute
func Async() hatmill.Attrib {
return hatmill.Attrib{
Key: "async",
}
}
// Autocapitalize creates a "autocapitalize" attribute
func Autocapitalize(value string) hatmill.Attrib {
return hatmill.Attrib{
Key: "autocapitalize",
Value: value,
}
}
// Autocomplete creates a "autocomplete" attribute
func Autocomplete(value string) hatmill.Attrib {
return hatmill.Attrib{
Key: "autocomplete",
Value: value,
}
}
// Autofocus creates a "autofocus" attribute
func Autofocus() hatmill.Attrib {
return hatmill.Attrib{
Key: "autofocus",
}
}
// Autoplay creates a "autoplay" attribute
func Autoplay() hatmill.Attrib {
return hatmill.Attrib{
Key: "autoplay",
}
}
// Buffered creates a "buffered" attribute
func Buffered(value string) hatmill.Attrib {
return hatmill.Attrib{
Key: "buffered",
Value: value,
}
}
// Challenge creates a "challenge" attribute
func Challenge(value string) hatmill.Attrib {
return hatmill.Attrib{
Key: "challenge",
Value: value,
}
}
// Charset creates a "charset" attribute
func Charset(value string) hatmill.Attrib {
return hatmill.Attrib{
Key: "charset",
Value: value,
}
}
// Checked creates a "checked" attribute
func Checked() hatmill.Attrib {
return hatmill.Attrib{
Key: "checked",
}
}
// Cite creates a "cite" attribute
func Cite(value string) hatmill.Attrib {
return hatmill.Attrib{
Key: "cite",
Value: value,
}
}
// Class creates a "class" attribute
func Class(value string) hatmill.Attrib {
return hatmill.Attrib{
Key: "class",
Value: value,
}
}
// Cols creates a "cols" attribute
func Cols(value string) hatmill.Attrib {
return hatmill.Attrib{
Key: "cols",
Value: value,
}
}
// Colspan creates a "colspan" attribute
func Colspan(value string) hatmill.Attrib {
return hatmill.Attrib{
Key: "colspan",
Value: value,
}
}
// Content creates a "content" attribute
func Content(value string) hatmill.Attrib {
return hatmill.Attrib{
Key: "content",
Value: value,
}
}
// Contenteditable creates a "contenteditable" attribute
func Contenteditable(value string) hatmill.Attrib {
return hatmill.Attrib{
Key: "contenteditable",
Value: value,
}
}
// Contextmenu creates a "contextmenu" attribute
func Contextmenu(value string) hatmill.Attrib {
return hatmill.Attrib{
Key: "contextmenu",
Value: value,
}
}
// Controls creates a "controls" attribute
func Controls() hatmill.Attrib {
return hatmill.Attrib{
Key: "controls",
}
}
// Coords creates a "coords" attribute
func Coords(value string) hatmill.Attrib {
return hatmill.Attrib{
Key: "coords",
Value: value,
}
}
// Crossorigin creates a "crossorigin" attribute
func Crossorigin(value string) hatmill.Attrib {
return hatmill.Attrib{
Key: "crossorigin",
Value: value,
}
}
// Datetime creates a "datetime" attribute
func Datetime(value string) hatmill.Attrib {
return hatmill.Attrib{
Key: "datetime",
Value: value,
}
}
// Decoding creates a "decoding" attribute
func Decoding(value string) hatmill.Attrib {
return hatmill.Attrib{
Key: "decoding",
Value: value,
}
}
// Default creates a "default" attribute
func Default() hatmill.Attrib {
return hatmill.Attrib{
Key: "default",
}
}
// Defer creates a "defer" attribute
func Defer() hatmill.Attrib {
return hatmill.Attrib{
Key: "defer",
}
}
// Dir creates a "dir" attribute
func Dir(value string) hatmill.Attrib {
return hatmill.Attrib{
Key: "dir",
Value: value,
}
}
// Dirname creates a "dirname" attribute
func Dirname(value string) hatmill.Attrib {
return hatmill.Attrib{
Key: "dirname",
Value: value,
}
}
// Disabled creates a "disabled" attribute // Disabled creates a "disabled" attribute
func Disabled() hatmill.Attrib { func Disabled() hatmill.Attrib {
return hatmill.Attrib{ return hatmill.Attrib{
@ -12,6 +261,125 @@ func Disabled() hatmill.Attrib {
} }
} }
// Download creates a "download" attribute
func Download(value string) hatmill.Attrib {
return hatmill.Attrib{
Key: "download",
Value: value,
}
}
// Draggable creates a "draggable" attribute
func Draggable(value string) hatmill.Attrib {
return hatmill.Attrib{
Key: "draggable",
Value: value,
}
}
// Dropzone creates a "dropzone" attribute
func Dropzone(value string) hatmill.Attrib {
return hatmill.Attrib{
Key: "dropzone",
Value: value,
}
}
// Enctype creates a "enctype" attribute
func Enctype(value string) hatmill.Attrib {
return hatmill.Attrib{
Key: "enctype",
Value: value,
}
}
// For creates a "for" attribute
func For(value string) hatmill.Attrib {
return hatmill.Attrib{
Key: "for",
Value: value,
}
}
// Form creates a "form" attribute
func Form(value string) hatmill.Attrib {
return hatmill.Attrib{
Key: "form",
Value: value,
}
}
// Formaction creates a "formaction" attribute
func Formaction(value string) hatmill.Attrib {
return hatmill.Attrib{
Key: "formaction",
Value: value,
}
}
// Headers creates a "headers" attribute
func Headers(value string) hatmill.Attrib {
return hatmill.Attrib{
Key: "headers",
Value: value,
}
}
// Height creates a "height" attribute
func Height(value string) hatmill.Attrib {
return hatmill.Attrib{
Key: "height",
Value: value,
}
}
// Hidden creates a "hidden" attribute
func Hidden() hatmill.Attrib {
return hatmill.Attrib{
Key: "hidden",
}
}
// High creates a "high" attribute
func High(value string) hatmill.Attrib {
return hatmill.Attrib{
Key: "high",
Value: value,
}
}
// Href creates a "href" attribute
func Href(value string) hatmill.Attrib {
return hatmill.Attrib{
Key: "href",
Value: value,
}
}
// Hreflang creates a "hreflang" attribute
func Hreflang(value string) hatmill.Attrib {
return hatmill.Attrib{
Key: "hreflang",
Value: value,
}
}
// HttpEquiv creates a "http-equiv" attribute
func HttpEquiv(value string) hatmill.Attrib {
return hatmill.Attrib{
Key: "http-equiv",
Value: value,
}
}
// Icon creates a "icon" attribute
func Icon(value string) hatmill.Attrib {
return hatmill.Attrib{
Key: "icon",
Value: value,
}
}
// Id creates a "id" attribute // Id creates a "id" attribute
func Id(value string) hatmill.Attrib { func Id(value string) hatmill.Attrib {
return hatmill.Attrib{ return hatmill.Attrib{
@ -20,6 +388,356 @@ func Id(value string) hatmill.Attrib {
} }
} }
// Integrity creates a "integrity" attribute
func Integrity(value string) hatmill.Attrib {
return hatmill.Attrib{
Key: "integrity",
Value: value,
}
}
// Ismap creates a "ismap" attribute
func Ismap() hatmill.Attrib {
return hatmill.Attrib{
Key: "ismap",
}
}
// Itemprop creates a "itemprop" attribute
func Itemprop(value string) hatmill.Attrib {
return hatmill.Attrib{
Key: "itemprop",
Value: value,
}
}
// Keytype creates a "keytype" attribute
func Keytype(value string) hatmill.Attrib {
return hatmill.Attrib{
Key: "keytype",
Value: value,
}
}
// Kind creates a "kind" attribute
func Kind(value string) hatmill.Attrib {
return hatmill.Attrib{
Key: "kind",
Value: value,
}
}
// Label creates a "label" attribute
func Label(value string) hatmill.Attrib {
return hatmill.Attrib{
Key: "label",
Value: value,
}
}
// Lang creates a "lang" attribute
func Lang(value string) hatmill.Attrib {
return hatmill.Attrib{
Key: "lang",
Value: value,
}
}
// Language creates a "language" attribute
func Language(value string) hatmill.Attrib {
return hatmill.Attrib{
Key: "language",
Value: value,
}
}
// List creates a "list" attribute
func List(value string) hatmill.Attrib {
return hatmill.Attrib{
Key: "list",
Value: value,
}
}
// Loop creates a "loop" attribute
func Loop() hatmill.Attrib {
return hatmill.Attrib{
Key: "loop",
}
}
// Low creates a "low" attribute
func Low(value string) hatmill.Attrib {
return hatmill.Attrib{
Key: "low",
Value: value,
}
}
// Manifest creates a "manifest" attribute
func Manifest(value string) hatmill.Attrib {
return hatmill.Attrib{
Key: "manifest",
Value: value,
}
}
// Max creates a "max" attribute
func Max(value string) hatmill.Attrib {
return hatmill.Attrib{
Key: "max",
Value: value,
}
}
// Maxlengh creates a "maxlengh" attribute
func Maxlengh(value string) hatmill.Attrib {
return hatmill.Attrib{
Key: "maxlengh",
Value: value,
}
}
// Media creates a "media" attribute
func Media(value string) hatmill.Attrib {
return hatmill.Attrib{
Key: "media",
Value: value,
}
}
// Method creates a "method" attribute
func Method(value string) hatmill.Attrib {
return hatmill.Attrib{
Key: "method",
Value: value,
}
}
// Min creates a "min" attribute
func Min(value string) hatmill.Attrib {
return hatmill.Attrib{
Key: "min",
Value: value,
}
}
// Minlength creates a "minlength" attribute
func Minlength(value string) hatmill.Attrib {
return hatmill.Attrib{
Key: "minlength",
Value: value,
}
}
// Multiple creates a "multiple" attribute
func Multiple() hatmill.Attrib {
return hatmill.Attrib{
Key: "multiple",
}
}
// Muted creates a "muted" attribute
func Muted() hatmill.Attrib {
return hatmill.Attrib{
Key: "muted",
}
}
// Name creates a "name" attribute
func Name(value string) hatmill.Attrib {
return hatmill.Attrib{
Key: "name",
Value: value,
}
}
// Novalidate creates a "novalidate" attribute
func Novalidate() hatmill.Attrib {
return hatmill.Attrib{
Key: "novalidate",
}
}
// Open creates a "open" attribute
func Open() hatmill.Attrib {
return hatmill.Attrib{
Key: "open",
}
}
// Optimum creates a "optimum" attribute
func Optimum(value string) hatmill.Attrib {
return hatmill.Attrib{
Key: "optimum",
Value: value,
}
}
// Pattern creates a "pattern" attribute
func Pattern(value string) hatmill.Attrib {
return hatmill.Attrib{
Key: "pattern",
Value: value,
}
}
// Ping creates a "ping" attribute
func Ping(value string) hatmill.Attrib {
return hatmill.Attrib{
Key: "ping",
Value: value,
}
}
// Placeholder creates a "placeholder" attribute
func Placeholder(value string) hatmill.Attrib {
return hatmill.Attrib{
Key: "placeholder",
Value: value,
}
}
// Poster creates a "poster" attribute
func Poster(value string) hatmill.Attrib {
return hatmill.Attrib{
Key: "poster",
Value: value,
}
}
// Preload creates a "preload" attribute
func Preload(value string) hatmill.Attrib {
return hatmill.Attrib{
Key: "preload",
Value: value,
}
}
// Readonly creates a "readonly" attribute
func Readonly() hatmill.Attrib {
return hatmill.Attrib{
Key: "readonly",
}
}
// Referrerpolicy creates a "referrerpolicy" attribute
func Referrerpolicy(value string) hatmill.Attrib {
return hatmill.Attrib{
Key: "referrerpolicy",
Value: value,
}
}
// Rel creates a "rel" attribute
func Rel(value string) hatmill.Attrib {
return hatmill.Attrib{
Key: "rel",
Value: value,
}
}
// Required creates a "required" attribute
func Required() hatmill.Attrib {
return hatmill.Attrib{
Key: "required",
}
}
// Reversed creates a "reversed" attribute
func Reversed() hatmill.Attrib {
return hatmill.Attrib{
Key: "reversed",
}
}
// Rows creates a "rows" attribute
func Rows(value string) hatmill.Attrib {
return hatmill.Attrib{
Key: "rows",
Value: value,
}
}
// Rowspan creates a "rowspan" attribute
func Rowspan(value string) hatmill.Attrib {
return hatmill.Attrib{
Key: "rowspan",
Value: value,
}
}
// Sandbox creates a "sandbox" attribute
func Sandbox(value string) hatmill.Attrib {
return hatmill.Attrib{
Key: "sandbox",
Value: value,
}
}
// Scope creates a "scope" attribute
func Scope(value string) hatmill.Attrib {
return hatmill.Attrib{
Key: "scope",
Value: value,
}
}
// Selected creates a "selected" attribute
func Selected() hatmill.Attrib {
return hatmill.Attrib{
Key: "selected",
}
}
// Shape creates a "shape" attribute
func Shape(value string) hatmill.Attrib {
return hatmill.Attrib{
Key: "shape",
Value: value,
}
}
// Size creates a "size" attribute
func Size(value string) hatmill.Attrib {
return hatmill.Attrib{
Key: "size",
Value: value,
}
}
// Sizes creates a "sizes" attribute
func Sizes(value string) hatmill.Attrib {
return hatmill.Attrib{
Key: "sizes",
Value: value,
}
}
// Slot creates a "slot" attribute
func Slot(value string) hatmill.Attrib {
return hatmill.Attrib{
Key: "slot",
Value: value,
}
}
// Span creates a "span" attribute
func Span(value string) hatmill.Attrib {
return hatmill.Attrib{
Key: "span",
Value: value,
}
}
// Spellcheck creates a "spellcheck" attribute
func Spellcheck(value string) hatmill.Attrib {
return hatmill.Attrib{
Key: "spellcheck",
Value: value,
}
}
// Src creates a "src" attribute // Src creates a "src" attribute
func Src(value string) hatmill.Attrib { func Src(value string) hatmill.Attrib {
return hatmill.Attrib{ return hatmill.Attrib{
@ -27,3 +745,131 @@ func Src(value string) hatmill.Attrib {
Value: value, Value: value,
} }
} }
// Srcdoc creates a "srcdoc" attribute
func Srcdoc(value string) hatmill.Attrib {
return hatmill.Attrib{
Key: "srcdoc",
Value: value,
}
}
// Srclang creates a "srclang" attribute
func Srclang(value string) hatmill.Attrib {
return hatmill.Attrib{
Key: "srclang",
Value: value,
}
}
// Srcset creates a "srcset" attribute
func Srcset(value string) hatmill.Attrib {
return hatmill.Attrib{
Key: "srcset",
Value: value,
}
}
// Start creates a "start" attribute
func Start(value string) hatmill.Attrib {
return hatmill.Attrib{
Key: "start",
Value: value,
}
}
// Step creates a "step" attribute
func Step(value string) hatmill.Attrib {
return hatmill.Attrib{
Key: "step",
Value: value,
}
}
// Style creates a "style" attribute
func Style(value string) hatmill.Attrib {
return hatmill.Attrib{
Key: "style",
Value: value,
}
}
// Summary creates a "summary" attribute
func Summary(value string) hatmill.Attrib {
return hatmill.Attrib{
Key: "summary",
Value: value,
}
}
// Tabindex creates a "tabindex" attribute
func Tabindex(value string) hatmill.Attrib {
return hatmill.Attrib{
Key: "tabindex",
Value: value,
}
}
// Target creates a "target" attribute
func Target(value string) hatmill.Attrib {
return hatmill.Attrib{
Key: "target",
Value: value,
}
}
// Title creates a "title" attribute
func Title(value string) hatmill.Attrib {
return hatmill.Attrib{
Key: "title",
Value: value,
}
}
// Translate creates a "translate" attribute
func Translate(value string) hatmill.Attrib {
return hatmill.Attrib{
Key: "translate",
Value: value,
}
}
// Type creates a "type" attribute
func Type(value string) hatmill.Attrib {
return hatmill.Attrib{
Key: "type",
Value: value,
}
}
// Usemap creates a "usemap" attribute
func Usemap(value string) hatmill.Attrib {
return hatmill.Attrib{
Key: "usemap",
Value: value,
}
}
// Value creates a "value" attribute
func Value(value string) hatmill.Attrib {
return hatmill.Attrib{
Key: "value",
Value: value,
}
}
// Width creates a "width" attribute
func Width(value string) hatmill.Attrib {
return hatmill.Attrib{
Key: "width",
Value: value,
}
}
// Wrap creates a "wrap" attribute
func Wrap(value string) hatmill.Attrib {
return hatmill.Attrib{
Key: "wrap",
Value: value,
}
}

110
defs.json
View File

@ -1,8 +1,116 @@
{ {
"attributes": [ "attributes": [
{"name": "accept", "type": "string"},
{"name": "accept-charset", "type": "string"},
{"name": "accesskey", "type": "string"},
{"name": "action", "type": "string"},
{"name": "align", "type": "string"},
{"name": "allow", "type": "string"},
{"name": "alt", "type": "string"},
{"name": "async", "type": "bool"},
{"name": "autocapitalize", "type": "string"},
{"name": "autocomplete", "type": "string"},
{"name": "autofocus", "type": "bool"},
{"name": "autoplay", "type": "bool"},
{"name": "buffered", "type": "string"},
{"name": "challenge", "type": "string"},
{"name": "charset", "type": "string"},
{"name": "checked", "type": "bool"},
{"name": "cite", "type": "string"},
{"name": "class", "type": "string"},
{"name": "cols", "type": "string"},
{"name": "colspan", "type": "string"},
{"name": "content", "type": "string"},
{"name": "contenteditable", "type": "string"},
{"name": "contextmenu", "type": "string"},
{"name": "controls", "type": "bool"},
{"name": "coords", "type": "string"},
{"name": "crossorigin", "type": "string"},
{"name": "datetime", "type": "string"},
{"name": "decoding", "type": "string"},
{"name": "default", "type": "bool"},
{"name": "defer", "type": "bool"},
{"name": "dir", "type": "string"},
{"name": "dirname", "type": "string"},
{"name": "disabled", "type": "bool"}, {"name": "disabled", "type": "bool"},
{"name": "download", "type": "string"},
{"name": "draggable", "type": "string"},
{"name": "dropzone", "type": "string"},
{"name": "enctype", "type": "string"},
{"name": "for", "type": "string"},
{"name": "form", "type": "string"},
{"name": "formaction", "type": "string"},
{"name": "headers", "type": "string"},
{"name": "height", "type": "string"},
{"name": "hidden", "type": "bool"},
{"name": "high", "type": "string"},
{"name": "href", "type": "string"},
{"name": "hreflang", "type": "string"},
{"name": "http-equiv", "type": "string"},
{"name": "icon", "type": "string"},
{"name": "id", "type": "string"}, {"name": "id", "type": "string"},
{"name": "src", "type": "string"} {"name": "integrity", "type": "string"},
{"name": "ismap", "type": "bool"},
{"name": "itemprop", "type": "string"},
{"name": "keytype", "type": "string"},
{"name": "kind", "type": "string"},
{"name": "label", "type": "string"},
{"name": "lang", "type": "string"},
{"name": "language", "type": "string"},
{"name": "list", "type": "string"},
{"name": "loop", "type": "bool"},
{"name": "low", "type": "string"},
{"name": "manifest", "type": "string"},
{"name": "max", "type": "string"},
{"name": "maxlengh", "type": "string"},
{"name": "media", "type": "string"},
{"name": "method", "type": "string"},
{"name": "min", "type": "string"},
{"name": "minlength", "type": "string"},
{"name": "multiple", "type": "bool"},
{"name": "muted", "type": "bool"},
{"name": "name", "type": "string"},
{"name": "novalidate", "type": "bool"},
{"name": "open", "type": "bool"},
{"name": "optimum", "type": "string"},
{"name": "pattern", "type": "string"},
{"name": "ping", "type": "string"},
{"name": "placeholder", "type": "string"},
{"name": "poster", "type": "string"},
{"name": "preload", "type": "string"},
{"name": "readonly", "type": "bool"},
{"name": "referrerpolicy", "type": "string"},
{"name": "rel", "type": "string"},
{"name": "required", "type": "bool"},
{"name": "reversed", "type": "bool"},
{"name": "rows", "type": "string"},
{"name": "rowspan", "type": "string"},
{"name": "sandbox", "type": "string"},
{"name": "scope", "type": "string"},
{"name": "selected", "type": "bool"},
{"name": "shape", "type": "string"},
{"name": "size", "type": "string"},
{"name": "sizes", "type": "string"},
{"name": "slot", "type": "string"},
{"name": "span", "type": "string"},
{"name": "spellcheck", "type": "string"},
{"name": "src", "type": "string"},
{"name": "srcdoc", "type": "string"},
{"name": "srclang", "type": "string"},
{"name": "srcset", "type": "string"},
{"name": "start", "type": "string"},
{"name": "step", "type": "string"},
{"name": "style", "type": "string"},
{"name": "summary", "type": "string"},
{"name": "tabindex", "type": "string"},
{"name": "target", "type": "string"},
{"name": "title", "type": "string"},
{"name": "translate", "type": "string"},
{"name": "type", "type": "string"},
{"name": "usemap", "type": "string"},
{"name": "value", "type": "string"},
{"name": "width", "type": "string"},
{"name": "wrap", "type": "string"}
], ],
"elements": [ "elements": [
{"name": "a"}, {"name": "a"},

5
go.mod
View File

@ -1,3 +1,6 @@
module gitlab.codemonkeysoftware.net/b/hatmill module gitlab.codemonkeysoftware.net/b/hatmill
require github.com/leanovate/gopter v0.2.4 require (
github.com/golang/mock v1.2.0 // indirect
github.com/leanovate/gopter v0.2.4
)

2
go.sum
View File

@ -1,2 +1,4 @@
github.com/golang/mock v1.2.0 h1:28o5sBqPkBsMGnC6b4MvE2TzSr5/AT4c/1fLqVGIwlk=
github.com/golang/mock v1.2.0/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
github.com/leanovate/gopter v0.2.4 h1:U4YLBggDFhJdqQsG4Na2zX7joVTky9vHaj/AGEwSuXU= github.com/leanovate/gopter v0.2.4 h1:U4YLBggDFhJdqQsG4Na2zX7joVTky9vHaj/AGEwSuXU=
github.com/leanovate/gopter v0.2.4/go.mod h1:gNcbPWNEWRe4lm+bycKqxUYoH5uoVje5SkOJ3uoLer8= github.com/leanovate/gopter v0.2.4/go.mod h1:gNcbPWNEWRe4lm+bycKqxUYoH5uoVje5SkOJ3uoLer8=

View File

@ -182,7 +182,9 @@ func Example() {
userInput := "<script>launchMissiles();</script>" userInput := "<script>launchMissiles();</script>"
document := he.Html()( document := he.Html()(
he.Head()(), he.Head()(
he.Meta(ha.HttpEquiv("refresh"), ha.Content("5")),
),
he.Body()( he.Body()(
he.Div()( he.Div()(
he.Img(ha.Src("./me.jpg"), ha.Id("profile-photo")), he.Img(ha.Src("./me.jpg"), ha.Id("profile-photo")),
@ -192,5 +194,5 @@ func Example() {
), ),
) )
hatmill.WriteDocument(os.Stdout, document) 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> // Output: <!DOCTYPE html><html><head><meta http-equiv='refresh' content='5'></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>
} }

View File

@ -19,6 +19,14 @@ package %s
import "gitlab.codemonkeysoftware.net/b/hatmill" import "gitlab.codemonkeysoftware.net/b/hatmill"
` `
func identifier(s string) string {
words := strings.Split(s, "-")
for i, word := range words {
words[i] = strings.Title(word)
}
return strings.Join(words, "")
}
func fileHeader(packageName string) string { func fileHeader(packageName string) string {
return fmt.Sprintf(headerFmt, packageName) return fmt.Sprintf(headerFmt, packageName)
} }
@ -88,7 +96,7 @@ func (def AttribDef) Generate() string {
panic(fmt.Errorf("unknown attribute type: %v", def.Type)) panic(fmt.Errorf("unknown attribute type: %v", def.Type))
} }
return fmt.Sprintf(template, strings.Title(def.Name), def.Name) return fmt.Sprintf(template, identifier(def.Name), def.Name)
} }
type ElemDef struct { type ElemDef struct {
@ -125,7 +133,7 @@ func (def ElemDef) Generate() string {
if def.Void { if def.Void {
template = voidTemplate template = voidTemplate
} }
return fmt.Sprintf(template, strings.Title(def.Name), def.Name) return fmt.Sprintf(template, identifier(def.Name), def.Name)
} }
type Defs struct { type Defs struct {