hatmill/internal/codegen
2019-03-24 15:42:48 -06:00
..
codegen.go Use unified JSON file for codegen input 2019-03-24 15:42:48 -06:00
README.md Use unified JSON file for codegen input 2019-03-24 15:42:48 -06:00

codegen

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:

{
  "elements": [
    {"name": "div"},
    {"name": "img", "empty": true},
  ],
  "attributes": [
    {"name": "src", "type": "string"},
    {"name": "disabled", "type": "bool"}
  ]
}

The "empty" key can be omitted from an element definition and defaults to false.