parsing and templating improvements
This commit is contained in:
5
templates/footer.tmpl
Normal file
5
templates/footer.tmpl
Normal file
@@ -0,0 +1,5 @@
|
||||
{{ define "footer" }}
|
||||
<footer></footer>
|
||||
</body>
|
||||
</html>
|
||||
{{ end }}
|
||||
11
templates/frontmatter.tmpl
Normal file
11
templates/frontmatter.tmpl
Normal file
@@ -0,0 +1,11 @@
|
||||
{{ define "frontmatter" }}
|
||||
{{ range $key, $value := . }}
|
||||
{{ if $value.SubContent }}
|
||||
<h2>{{ splitCapitalize $value.Name }}</h2>
|
||||
{{ template "frontmatter" $value.Content }}
|
||||
{{ else}}
|
||||
<label for="{{ $value.Master }}_{{ $value.Name }}">{{ splitCapitalize $value.Name }}</label>
|
||||
<input name="{{ $value.Master }}_{{ $value.Name }}" id="{{ $value.Master }}_{{ $value.Name }}" value="{{ $value.Content }}"></input><br>
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
@@ -1,3 +1,4 @@
|
||||
{{ define "header" }}
|
||||
<!DOCTYPE html>
|
||||
<html class="no-js" lang="en">
|
||||
<head>
|
||||
@@ -20,9 +21,4 @@
|
||||
<header class="site-header">
|
||||
Admin
|
||||
</header>
|
||||
|
||||
{{ template "content" . }}
|
||||
|
||||
<footer></footer>
|
||||
</body>
|
||||
</html>
|
||||
{{ end }}
|
||||
@@ -1,30 +1,12 @@
|
||||
{{ define "optsLoop" }}
|
||||
{{ range $key, $value := . }}
|
||||
{{ if $value.SubContent }}
|
||||
<h2>{{ splitCapitalize $value.Name }}</h2>
|
||||
{{ template "optsLoop" $value.Content }}
|
||||
{{ else}}
|
||||
{{ template "header" . }}
|
||||
|
||||
<label for="{{ $value.Master }}_{{ $value.Name }}">{{ splitCapitalize $value.Name }}</label>
|
||||
<input name="{{ $value.Master }}_{{ $value.Name }}" id="{{ $value.Master }}_{{ $value.Name }}" value="{{ $value.Content }}"></input><br>
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
|
||||
|
||||
{{ define "content" }}
|
||||
{{ with .Body }}
|
||||
|
||||
<div class="content">
|
||||
|
||||
<h1>Settings</h1>
|
||||
|
||||
<form>
|
||||
{{ template "optsLoop" .Settings }}
|
||||
{{ template "frontmatter" .Settings }}
|
||||
</form>
|
||||
|
||||
|
||||
</div>
|
||||
{{ end }}
|
||||
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
{{ template "footer" . }}
|
||||
|
||||
Reference in New Issue
Block a user