Exemplo n.º 1
0
Arquivo: form.go Projeto: elos/gaia
func encodeString(name, quote string) []byte {
	return append(html.Must((&html.Label{
		For:   name,
		Label: path.Base(name),
	}).MarshalText()), html.Must((&html.Input{
		Type:  html.Input_TEXT,
		Name:  name,
		Value: quote,
	}).MarshalText())...)
}
Exemplo n.º 2
0
Arquivo: form.go Projeto: elos/gaia
func encodeBool(name string, quote bool) []byte {
	return append(html.Must((&html.Label{
		For:   name,
		Label: path.Base(name),
	}).MarshalText()), html.Must((&html.Input{
		Name:    name,
		Type:    html.Input_CHECKBOX,
		Checked: quote,
	}).MarshalText())...)
}
Exemplo n.º 3
0
Arquivo: form.go Projeto: elos/gaia
func encodeFloat(name string, quote float64) []byte {
	return append(html.Must((&html.Label{
		For:   name,
		Label: path.Base(name),
	}).MarshalText()), html.Must((&html.Input{
		Type:  html.Input_NUMBER,
		Name:  name,
		Value: fmt.Sprintf("%f", quote),
	}).MarshalText())...)
}
Exemplo n.º 4
0
Arquivo: form.go Projeto: elos/gaia
func encodeTime(name string, quote time.Time) []byte {
	return append(html.Must((&html.Label{
		For:   name,
		Label: path.Base(name),
	}).MarshalText()), html.Must((&html.Input{
		Name:  name,
		Type:  html.Input_DATETIME_LOCAL,
		Value: quote.Format(time.RFC3339),
	}).MarshalText())...)
}
Exemplo n.º 5
0
Arquivo: form.go Projeto: elos/gaia
func marshalComposite(name string, v reflect.Value) ([]byte, error) {
	bytes, err := json.MarshalIndent(v.Interface(), "", "	")
	if err != nil {
		return nil, err
	}

	return append(html.Must((&html.Label{
		For:   name,
		Label: path.Base(name),
	}).MarshalText()), html.Must((&html.TextArea{
		Name:    name,
		Content: string(bytes),
	}).MarshalText())...), nil
}