Renamed Empty to Void in codegen
This commit is contained in:
parent
4ebae3c948
commit
62026132a8
@ -9,7 +9,7 @@
|
|||||||
{"name": "div"},
|
{"name": "div"},
|
||||||
{"name": "head"},
|
{"name": "head"},
|
||||||
{"name": "html"},
|
{"name": "html"},
|
||||||
{"name": "img", "empty": true},
|
{"name": "img", "void": true},
|
||||||
{"name": "li"},
|
{"name": "li"},
|
||||||
{"name": "span"},
|
{"name": "span"},
|
||||||
{"name": "title"},
|
{"name": "title"},
|
||||||
|
@ -4,13 +4,13 @@ codegen reads JSON descriptions of HTML elements and attributes, and generates
|
|||||||
Go functions to create them.
|
Go functions to create them.
|
||||||
|
|
||||||
The input file consists of a JSON object like the following, which includes all
|
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": [
|
"elements": [
|
||||||
{"name": "div"},
|
{"name": "div"},
|
||||||
{"name": "img", "empty": true},
|
{"name": "img", "void": true},
|
||||||
],
|
],
|
||||||
"attributes": [
|
"attributes": [
|
||||||
{"name": "src", "type": "string"},
|
{"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`.
|
`false`.
|
||||||
|
@ -99,7 +99,7 @@ func (def AttribDef) Generate(qualified bool) string {
|
|||||||
|
|
||||||
type ElemDef struct {
|
type ElemDef struct {
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
Empty bool `json:"empty"`
|
Void bool `json:"void"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (def ElemDef) Generate(qualified bool) string {
|
func (def ElemDef) Generate(qualified bool) string {
|
||||||
@ -132,7 +132,7 @@ func (def ElemDef) Generate(qualified bool) string {
|
|||||||
pkg = "hatmill."
|
pkg = "hatmill."
|
||||||
}
|
}
|
||||||
template := parentTemplate
|
template := parentTemplate
|
||||||
if def.Empty {
|
if def.Void {
|
||||||
template = voidTemplate
|
template = voidTemplate
|
||||||
}
|
}
|
||||||
return fmt.Sprintf(template, strings.Title(def.Name), def.Name, pkg)
|
return fmt.Sprintf(template, strings.Title(def.Name), def.Name, pkg)
|
||||||
|
Loading…
Reference in New Issue
Block a user