diff options
author | Steve Manuel <nilslice@gmail.com> | 2016-09-30 20:11:28 -0400 |
---|---|---|
committer | Steve Manuel <nilslice@gmail.com> | 2016-09-30 20:11:28 -0400 |
commit | 43c77865f82fefffbb89ccfb599dfa1e9c6c8f31 (patch) | |
tree | 6c2e76ff83477f27d775a461c7a1b45c37958f73 /cmd/cms/options.go | |
parent | f2a151f2696e92d27f1e674bc02850dff7d3cd3c (diff) |
updating generated content types to include more built-in input function examples (+ Select, Checkbox)
Diffstat (limited to 'cmd/cms/options.go')
-rw-r--r-- | cmd/cms/options.go | 34 |
1 files changed, 25 insertions, 9 deletions
diff --git a/cmd/cms/options.go b/cmd/cms/options.go index 3b6db8c..a1843b3 100644 --- a/cmd/cms/options.go +++ b/cmd/cms/options.go @@ -65,13 +65,13 @@ type {{ .name }} struct { Item editor editor.Editor -/* - // all your custom fields must have json tags! - Title string ` + "`json:" + `"title"` + "`" + ` - Content string ` + "`json:" + `"content"` + "`" + ` - Author string ` + "`json:" + `"author"` + "`" + ` - Timestamp string ` + "`json:" + `"timestamp"` + "`" + ` -*/ + // required: all maintained {{ .name }} fields must have json tags! + Title string ` + "`json:" + `"title"` + "`" + ` + Content string ` + "`json:" + `"content"` + "`" + ` + Author string ` + "`json:" + `"author"` + "`" + ` + Category []string ` + "`json:" + `"category"` + "`" + ` + ThemeStyle string ` + "`json:" + `"theme"` + "`" + ` + Timestamp string ` + "`json:" + `"timestamp"` + "`" + ` } func init() { @@ -95,7 +95,7 @@ func ({{ .initial }} *{{ .name }}) Editor() *editor.Editor { return &{{ .initial // MarshalEditor writes a buffer of html to edit a {{ .name }} and partially implements editor.Editable func ({{ .initial }} *{{ .name }}) MarshalEditor() ([]byte, error) { -/* EXAMPLE CODE (from post.go, the default content type) +/* EXAMPLE CODE (from post.go, the default content type) */ view, err := editor.Form({{ .initial }}, editor.Field{ // Take careful note that the first argument to these Input-like methods @@ -129,6 +129,23 @@ func ({{ .initial }} *{{ .name }}) MarshalEditor() ([]byte, error) { }), }, editor.Field{ + View: editor.Checkbox("Category", {{ .initial }}, map[string]string{ + "label": "{{ .name }} Category", + }, map[string]string{ + "important": "Important", + "active": "Active", + "unplanned": "Unplanned", + }), + }, + editor.Field{ + View: editor.Select("ThemeStyle", {{ .initial }}, map[string]string{ + "label": "Theme Style", + }, map[string]string{ + "dark": "Dark", + "light": "Light", + }), + }, + editor.Field{ View: editor.Input("Timestamp", {{ .initial }}, map[string]string{ "label": "Publish Date", "type": "date", @@ -141,7 +158,6 @@ func ({{ .initial }} *{{ .name }}) MarshalEditor() ([]byte, error) { } return view, nil -*/ } ` |