Exemple #1
0
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())...)
}
Exemple #2
0
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())...)
}
Exemple #3
0
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())...)
}
Exemple #4
0
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())...)
}
Exemple #5
0
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
}