diff options
author | Steve Manuel <nilslice@gmail.com> | 2017-04-01 12:17:58 -0700 |
---|---|---|
committer | Steve Manuel <nilslice@gmail.com> | 2017-04-01 12:17:58 -0700 |
commit | dc78fc53fbfb1d10c9673c02b7741ce1b45eb724 (patch) | |
tree | f5d7aa1f1e97b8b535cf7f49dee547507b40735b /cmd | |
parent | 75195ecb39c8178a3a2cd8d8a6c4a8bbeaab2a39 (diff) |
adding cases and templates for checkbox, file, richtext, select, tags, textarea
Diffstat (limited to 'cmd')
-rw-r--r-- | cmd/ponzu/generate.go | 25 | ||||
-rw-r--r-- | cmd/ponzu/templates/gen-checkbox.tmpl | 5 | ||||
-rw-r--r-- | cmd/ponzu/templates/gen-custom.tmpl | 8 | ||||
-rw-r--r-- | cmd/ponzu/templates/gen-file.tmpl | 4 | ||||
-rw-r--r-- | cmd/ponzu/templates/gen-richtext.tmpl | 4 | ||||
-rw-r--r-- | cmd/ponzu/templates/gen-select.tmpl | 5 | ||||
-rw-r--r-- | cmd/ponzu/templates/gen-tags.tmpl | 4 | ||||
-rw-r--r-- | cmd/ponzu/templates/gen-textarea.tmpl | 4 |
8 files changed, 46 insertions, 13 deletions
diff --git a/cmd/ponzu/generate.go b/cmd/ponzu/generate.go index 62655f0..3536212 100644 --- a/cmd/ponzu/generate.go +++ b/cmd/ponzu/generate.go @@ -154,21 +154,28 @@ func setFieldView(field *generateField, viewType string) error { return template.ParseFiles(filepath.Join(tmplDir, filename)) } - switch strings.ToLower(viewType) { + viewType = strings.ToLower(viewType) + switch viewType { + case "checkbox": + tmpl, err = tmplFrom("gen-checkbox.tmpl") + case "custom": + tmpl, err = tmplFrom("gen-custom.tmpl") + case "file": + tmpl, err = tmplFrom("gen-file.tmpl") case "hidden": tmpl, err = tmplFrom("gen-hidden.tmpl") - case "textarea": + case "input", "text": + tmpl, err = tmplFrom("gen-input.tmpl") case "richtext": + tmpl, err = tmplFrom("gen-richtext.tmpl") case "select": - case "input": - tmpl, err = tmplFrom("gen-input.tmpl") - case "checkbox": - case "file": + tmpl, err = tmplFrom("gen-select.tmpl") + case "textarea": + tmpl, err = tmplFrom("gen-textarea.tmpl") case "tags": - case "custom": - tmpl, err = tmplFrom("gen-custom.tmpl") + tmpl, err = tmplFrom("gen-tags.tmpl") default: - msg := fmt.Sprintf("'%s' is not a recognized view type. Using 'input' instead.") + msg := fmt.Sprintf("'%s' is not a recognized view type. Using 'input' instead.", viewType) fmt.Println(msg) tmpl, err = tmplFrom("gen-input.tmpl") } diff --git a/cmd/ponzu/templates/gen-checkbox.tmpl b/cmd/ponzu/templates/gen-checkbox.tmpl new file mode 100644 index 0000000..23713dc --- /dev/null +++ b/cmd/ponzu/templates/gen-checkbox.tmpl @@ -0,0 +1,5 @@ +View: editor.Checkbox("{{ .Name }}", {{ .Initial }}, map[string]string{ + "label": "{{ .Name }}", +}, map[string]string{ + // "value": "Display Name", +}),
\ No newline at end of file diff --git a/cmd/ponzu/templates/gen-custom.tmpl b/cmd/ponzu/templates/gen-custom.tmpl index a578d18..a1e0552 100644 --- a/cmd/ponzu/templates/gen-custom.tmpl +++ b/cmd/ponzu/templates/gen-custom.tmpl @@ -1,6 +1,6 @@ View: []byte(` - <div class="input-field col s12"> - <label class="active">{{ .Name }}</label> - <!-- Add your custom editor field view here. --> - </div> + <div class="input-field col s12"> + <label class="active">{{ .Name }}</label> + <!-- Add your custom editor field view here. --> + </div> `),
\ No newline at end of file diff --git a/cmd/ponzu/templates/gen-file.tmpl b/cmd/ponzu/templates/gen-file.tmpl new file mode 100644 index 0000000..7bcaa4c --- /dev/null +++ b/cmd/ponzu/templates/gen-file.tmpl @@ -0,0 +1,4 @@ +View: editor.File("{{ .Name }}", {{ .Initial }}, map[string]string{ + "label": "{{ .Name }}", + "placeholder": "Upload the {{ .Name }} here", +}),
\ No newline at end of file diff --git a/cmd/ponzu/templates/gen-richtext.tmpl b/cmd/ponzu/templates/gen-richtext.tmpl new file mode 100644 index 0000000..c7ec18c --- /dev/null +++ b/cmd/ponzu/templates/gen-richtext.tmpl @@ -0,0 +1,4 @@ +View: editor.Richtext("{{ .Name }}", {{ .Initial }}, map[string]string{ + "label": "{{ .Name }}", + "placeholder": "Enter the {{ .Name }} here", +}),
\ No newline at end of file diff --git a/cmd/ponzu/templates/gen-select.tmpl b/cmd/ponzu/templates/gen-select.tmpl new file mode 100644 index 0000000..509eb30 --- /dev/null +++ b/cmd/ponzu/templates/gen-select.tmpl @@ -0,0 +1,5 @@ +View: editor.Select("{{ .Name }}", {{ .Initial }}, map[string]string{ + "label": "{{ .Name }}", +}, map[string]string{ + // "value": "Display Name", +}),
\ No newline at end of file diff --git a/cmd/ponzu/templates/gen-tags.tmpl b/cmd/ponzu/templates/gen-tags.tmpl new file mode 100644 index 0000000..ca92c94 --- /dev/null +++ b/cmd/ponzu/templates/gen-tags.tmpl @@ -0,0 +1,4 @@ +View: editor.Tags("{{ .Name }}", {{ .Initial }}, map[string]string{ + "label": "{{ .Name }}", + "placeholder": "+{{ .Name }}", +}),
\ No newline at end of file diff --git a/cmd/ponzu/templates/gen-textarea.tmpl b/cmd/ponzu/templates/gen-textarea.tmpl new file mode 100644 index 0000000..af3dad8 --- /dev/null +++ b/cmd/ponzu/templates/gen-textarea.tmpl @@ -0,0 +1,4 @@ +View: editor.Textarea("{{ .Name }}", {{ .Initial }}, map[string]string{ + "label": "{{ .Name }}", + "placeholder": "Enter the {{ .Name }} here", +}),
\ No newline at end of file |