Renamed Empty to Void in codegen

This commit is contained in:
Brandon Dyck 2019-03-28 20:22:31 -06:00
parent 4ebae3c948
commit 62026132a8
3 changed files with 6 additions and 6 deletions

View File

@ -9,7 +9,7 @@
{"name": "div"},
{"name": "head"},
{"name": "html"},
{"name": "img", "empty": true},
{"name": "img", "void": true},
{"name": "li"},
{"name": "span"},
{"name": "title"},

View File

@ -4,13 +4,13 @@ codegen reads JSON descriptions of HTML elements and attributes, and generates
Go functions to create them.
The input file consists of a JSON object like the following, which includes all
options for attribute types and element emptiness:
options for attribute types and element voidnesss:
```
{
"elements": [
{"name": "div"},
{"name": "img", "empty": true},
{"name": "img", "void": true},
],
"attributes": [
{"name": "src", "type": "string"},
@ -19,5 +19,5 @@ options for attribute types and element emptiness:
}
```
The `"empty"` key can be omitted from an element definition and defaults to
The `"void"` key can be omitted from an element definition and defaults to
`false`.

View File

@ -99,7 +99,7 @@ func (def AttribDef) Generate(qualified bool) string {
type ElemDef struct {
Name string `json:"name"`
Empty bool `json:"empty"`
Void bool `json:"void"`
}
func (def ElemDef) Generate(qualified bool) string {
@ -132,7 +132,7 @@ func (def ElemDef) Generate(qualified bool) string {
pkg = "hatmill."
}
template := parentTemplate
if def.Empty {
if def.Void {
template = voidTemplate
}
return fmt.Sprintf(template, strings.Title(def.Name), def.Name, pkg)