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

64 lines
2.1 KiB
Cheetah

{{ define "blocks" }}
{{ 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 }}
<div class="action delete" data-delete="{{ $value.Name }}-{{ $key }}">
<i class="material-icons">close</i>
</div>
</div>
{{ else }}
<div class="block" id="block-{{ $value.Name }}" data-content="{{ $value.Name }}">
<label for="{{ $value.Name }}">{{ SplitCapitalize $value.Title }}</label>
{{ template "value" $value }}
<div class="action delete" data-delete="block-{{ $value.Name }}">
<i class="material-icons">close</i>
</div>
</div>
{{ end }}
{{ end }}
{{ if .Fields }}</div>{{ end }}
{{ range $key, $value := .Arrays }}
{{ template "fielset" $value }}
{{ end }}
{{ range $key, $value := .Objects }}
{{ template "fielset" $value }}
{{ end }}
<template id="arrayItem">
</template>
<template id="objectItem">
</template>
{{ end }}
{{ define "value" }}
{{ if eq .HTMLType "textarea" }}
<textarea class="scroll" name="{{ .Name }}:{{ .Type }}" id="{{.Name }}" data-parent-type="{{ .Parent.Type }}">{{ .Content.Other }}</textarea>
{{ else if eq .HTMLType "datetime" }}
<input name="{{ .Name }}:{{ .Type }}" id="{{ .Name }}" value="{{ .Content.Other.Format "2006-01-02T15:04" }}" type="datetime-local" data-parent-type="{{ .Parent.Type }}"></input>
{{ else }}
<input name="{{ .Name }}:{{ .Type }}" id="{{ .Name }}" value="{{ .Content.Other }}" type="{{ .HTMLType }}" data-parent-type="{{ .Parent.Type }}"></input>
{{ end }}
{{ end }}
{{ define "fielset" }}
<fieldset id="{{ .Name }}" data-type="{{ .Type }}">
<h3>{{ SplitCapitalize .Title }}</h3>
<div class="action add">
<i class="material-icons">add</i>
</div>
<div class="action delete" data-delete="{{ .Name }}">
<i class="material-icons">close</i>
</div>
{{ template "blocks" .Content }}
</fieldset>
{{ end }}