filebrowser/assets/templates/frontmatter.tmpl
2016-06-07 22:02:14 +01:00

40 lines
1.7 KiB
Cheetah

{{ define "frontmatter" }}
{{ range $key, $value := . }}
{{ if or (eq $value.Type "object") (eq $value.Type "array") }}
<fieldset id="{{ $value.Name }}" data-type="{{ $value.Type }}">
<h3>{{ SplitCapitalize $value.Title }}</h3>
<button class="delete">remove</button>
{{ if (eq $value.Type "array") }}<div class="itens">{{ end }}{{ template "frontmatter" $value.Content }}{{ if (eq $value.Type "array") }}<button class="add">&#43;</button></div>{{ end }}
</fieldset>
{{ else }}
{{ if not (eq $value.Parent.Type "array") }}
<div class="block" id="block-{{ $value.Name }}" data-content="{{ $value.Name }}">
<label for="{{ $value.Name }}">{{ SplitCapitalize $value.Title }}</label>
<button class="delete">remove</button>
{{ end }}
{{ if eq $value.Parent.Type "array" }}
<div id="{{ $value.Name }}-{{ $key }}" data-type="array-item">
{{ end }}
{{ if eq $value.HTMLType "textarea" }}
<textarea class="scroll" name="{{ $value.Name }}:{{ $value.Type }}" id="{{ $value.Name }}" data-parent-type="{{ $value.Parent.Type }}">{{ $value.Content }}</textarea>
{{ else if eq $value.HTMLType "datetime" }}
<input name="{{ $value.Name }}:{{ $value.Type }}" id="{{ $value.Name }}" value="{{ $value.Content.Format "2006-01-02T15:04" }}" type="datetime-local" data-parent-type="{{ $value.Parent.Type }}"></input>
{{ else }}
<input name="{{ $value.Name }}:{{ $value.Type }}" id="{{ $value.Name }}" value="{{ $value.Content }}" type="{{ $value.HTMLType }}" data-parent-type="{{ $value.Parent.Type }}"></input>
{{ end }}
{{ if not (eq $value.Parent.Type "array") }}</div>{{ end }}
{{ if eq $value.Parent.Type "array" }}
<span class="actions"><button class="delete">&#215;</button></span></div>
{{ end }}
{{ end }}
{{ end }}
{{ end }}