func DOMElementSelfClose(e *Element) []byte {
	_, err := e.ViewBuf.WriteString(`<div class="input-field col s12">`)
	if err != nil {
		log.Println("Error writing HTML string to buffer: DOMElementSelfClose")
		return nil
	}
	if e.Label != "" {
		_, err = e.ViewBuf.WriteString(
			`<label class="active" for="` +
				strings.Join(strings.Split(e.Label, " "), "-") + `">` + e.Label +
				`</label>`)
		if err != nil {
			log.Println("Error writing HTML string to buffer: DOMElementSelfClose")
			return nil
		}
	}
	_, err = e.ViewBuf.WriteString(`<` + e.TagName + ` value="`)
	if err != nil {
		log.Println("Error writing HTML string to buffer: DOMElementSelfClose")
		return nil
	}
	_, err = e.ViewBuf.WriteString(html.EscapeString(e.Data) + `" `)
	if err != nil {
		log.Println("Error writing HTML string to buffer: DOMElementSelfClose")
		return nil
	}
	for attr, value := range e.Attrs {
		_, err := e.ViewBuf.WriteString(attr + `="` + value + `" `)
		if err != nil {
			log.Println("Error writing HTML string to buffer: DOMElementSelfClose")
			return nil
		}
	}
	_, err = e.ViewBuf.WriteString(` name="` + e.Name + `" />`)
	if err != nil {
		log.Println("Error writing HTML string to buffer: DOMElementSelfClose")
		return nil
	}
	_, err = e.ViewBuf.WriteString(`</div>`)
	if err != nil {
		log.Println("Error writing HTML string to buffer: DOMElementSelfClose")
		return nil
	}
	return e.ViewBuf.Bytes()
}
DOMElementSelfClose is a special DOM element which is parsed as a
self-closing tag and thus needs to be created differently
package editor
import (
	"bytes"
	"html"
	"log"
	"strings"
)
type Element struct {
	TagName string
	Attrs   map[string]string
	Name    string
	Label   string
	Data    string
	ViewBuf *bytes.Buffer
}
func NewElement(tagName, label, fieldName string, p interface{}, attrs map[string]string) *Element {
	return &Element{
		TagName: tagName,
		Attrs:   attrs,
		Name:    TagNameFromStructField(fieldName, p),
		Label:   label,
		Data:    ValueFromStructField(fieldName, p),
		ViewBuf: &bytes.Buffer{},
	}
}