示例#1
0
文件: form.go 项目: 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())...)
}
示例#2
0
文件: form.go 项目: 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())...)
}
示例#3
0
文件: form.go 项目: 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())...)
}
示例#4
0
文件: form.go 项目: 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())...)
}
示例#5
0
文件: form.go 项目: 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
}