update templates

pull/144/head
Henrique Dias 2016-12-31 10:53:48 +00:00
parent 0ceb15fde3
commit 0a3ca3a149
2 changed files with 70 additions and 75 deletions

View File

@ -2,15 +2,14 @@
{{ with .Data }}
<div id="editor" class="container" data-kind="{{ .Class }}">
<form method="POST" action="./">
{{ if or (eq .Class "frontmatter-only") (eq .Class "complete") }}
{{- if or (eq .Class "frontmatter-only") (eq .Class "complete") }}
<div class="frontmatter" data-type="parent">
{{ template "blocks" .FrontMatter }}
{{- template "blocks" .FrontMatter }}
<div class="button add">Add field</div>
</div>
{{ end }}
{{- end }}
{{ if or (eq .Class "content-only") (eq .Class "complete") }}
{{ if (eq .Class "complete")}}
<h3>Body</h3>
{{ end }}

View File

@ -1,16 +1,14 @@
{{ define "blocks" }}
{{ if .Fields }}
<div class="group">
{{ end }}
{{ range $key, $value := .Fields }}
{{ if eq $value.Parent.Type "array" }}
{{ if .Fields }}<div class="group">{{ end }}
{{- range $key, $value := .Fields }}
{{- if eq $value.Parent.Type "array" }}
<div id="{{ $value.Name }}-{{ $key }}" data-type="array-item">
{{ template "value" $value }}
{{- template "value" $value }}
<div class="action delete" data-delete="{{ $value.Name }}-{{ $key }}">
<i class="material-icons" title="Close">close</i>
</div>
</div>
{{ else }}
{{- else }}
<div class="block" id="block-{{ $value.Name }}" data-content="{{ $value.Name }}">
<label for="{{ $value.Name }}">{{ $value.Title }}</label>
{{ template "value" $value }}
@ -18,43 +16,41 @@
<i class="material-icons" title="Close">close</i>
</div>
</div>
{{ end }}
{{ end }}
{{ if .Fields }}
</div>
{{ end }}
{{- end }}
{{- end }}
{{- if .Fields }}</div>{{ end }}
{{ range $key, $value := .Arrays }}
{{ template "fielset" $value }}
{{ end }}
{{- range $key, $value := .Arrays }}
{{- template "fielset" $value }}
{{- end }}
{{ range $key, $value := .Objects }}
{{ template "fielset" $value }}
{{ end }}
{{- range $key, $value := .Objects }}
{{- template "fielset" $value }}
{{- end }}
{{ end }}
{{ define "value" }}
{{ if eq .HTMLType "textarea" }}
{{- if eq .HTMLType "textarea" }}
<textarea class="scroll" name="{{ .Name }}" id="{{.Name }}" data-parent-type="{{ .Parent.Type }}">{{ .Content.Other }}</textarea>
{{ else if eq .HTMLType "datetime" }}
{{- else if eq .HTMLType "datetime" }}
<input name="{{ .Name }}" id="{{ .Name }}" value="{{ .Content.Other.Format "2006-01-02T15:04" }}" type="datetime-local" data-parent-type="{{ .Parent.Type }}"></input>
{{ else }}
{{- else }}
<input name="{{ .Name }}" id="{{ .Name }}" value="{{ .Content.Other }}" type="{{ .HTMLType }}" data-parent-type="{{ .Parent.Type }}"></input>
{{ end }}
{{- end }}
{{ end }}
{{ define "fielset" }}
<fieldset id="{{ .Name }}" data-type="{{ .Type }}">
{{ if not (eq .Title "") }}
{{- if not (eq .Title "") }}
<h3>{{ .Title }}</h3>
{{ end }}
{{- end }}
<div class="action add">
<i class="material-icons" title="Add">add</i>
</div>
<div class="action delete" data-delete="{{ .Name }}">
<i class="material-icons" title="Close">close</i>
</div>
{{ template "blocks" .Content }}
{{- template "blocks" .Content }}
</fieldset>
{{ end }}