partials handling

This commit is contained in:
Sebastian Frank 2019-02-12 19:36:11 +01:00
parent c35cfec291
commit 7d408f5b7e
Signed by: apairon
GPG Key ID: 7270D06DDA7FE8C3
6 changed files with 63 additions and 59 deletions

View File

@ -1,39 +1,12 @@
<html>
<meta>
<title>{{ Meta.Title }}</title>
<meta name="description" content="{{ Meta.Description }}" />
<meta name="keywords" content="{{ Meta.Keywords }}" />
<style>
a {
color: black;
}
body {
color: #333;
}
</style>
</meta>
{{> meta.html }}
<body style="margin: 0; padding: 2;">
<header style="background-color: lightgrey; padding: 20px;">
<div><img src="../assets/img/logo.png" style="max-width: 80%; margin-bottom: 20px;"></div>
<div><b>main Level 1</b></div>
<ul>
{{#each NavMap.de.SubMap.main.SubSlice }}
<li><a href="{{ GoTo }}">{{ Navname }}</a></li>
{{/each}}
</ul>
</header>
{{> header.html }}
<div style="padding: 20px;">
{{{ Body }}}
</div>
<footer style="background-color: lightgrey; padding: 20px;">
<div><b>service Level 1</b></div>
<ul>
{{#each NavMap.de.SubMap.service.SubSlice }}
<li><a href="{{ GoTo }}">{{ Navname }}</a></li>
{{/each}}
</ul>
</footer>
{{> footer.html }}
</body>
</html>

View File

@ -1,26 +1,7 @@
<html>
<meta>
<title>{{ Meta.Title }}</title>
<meta name="description" content="{{ Meta.Description }}" />
<meta name="keywords" content="{{ Meta.Keywords }}" />
<style>
a {
color: black;
}
body {
color: #333;
}
</style>
</meta>
{{> meta.html }}
<body style="margin: 0; padding: 2;">
<header style="background-color: lightgrey; padding: 20px;">
<div><b>main Level 1</b></div>
<ul>
{{#each NavMap.de.SubMap.main.SubSlice }}
<li><a href="{{ GoTo }}">{{ Navname }}</a></li>
{{/each}}
</ul>
</header>
{{> header.html }}
<div style="padding: 20px;">
{{{ Body }}}
@ -30,13 +11,6 @@
</pre>
</div>
<footer style="background-color: lightgrey; padding: 20px;">
<div><b>service Level 1</b></div>
<ul>
{{#each NavMap.de.SubMap.service.SubSlice }}
<li><a href="{{ GoTo }}">{{ Navname }}</a></li>
{{/each}}
</ul>
</footer>
{{> footer.html }}
</body>
</html>

View File

@ -0,0 +1,8 @@
<footer style="background-color: lightgrey; padding: 20px;">
<div><b>service Level 1</b></div>
<ul>
{{#each NavMap.de.SubMap.service.SubSlice }}
<li><a href="{{ GoTo }}">{{ Navname }}</a></li>
{{/each}}
</ul>
</footer>

View File

@ -0,0 +1,9 @@
<header style="background-color: lightgrey; padding: 20px;">
<div><img src="../assets/img/logo.png" style="max-width: 80%; margin-bottom: 20px;"></div>
<div><b>main Level 1</b></div>
<ul>
{{#each NavMap.de.SubMap.main.SubSlice }}
<li><a href="{{ GoTo }}">{{ Navname }}</a></li>
{{/each}}
</ul>
</header>

View File

@ -0,0 +1,13 @@
<meta>
<title>{{ Meta.Title }}</title>
<meta name="description" content="{{ Meta.Description }}" />
<meta name="keywords" content="{{ Meta.Keywords }}" />
<style>
a {
color: black;
}
body {
color: #333;
}
</style>
</meta>

27
main.go
View File

@ -573,6 +573,33 @@ func main() {
//spew.Dump(navMap)
partialsPath := *inDir + "/templates/partials"
if d, err := os.Stat(partialsPath); !os.IsNotExist(err) {
if d != nil && d.IsDir() {
log.Debugf("register template partials from '%s'", partialsPath)
if entries, err := ioutil.ReadDir(partialsPath); err == nil {
for _, f := range entries {
if !f.IsDir() {
pFile := partialsPath + "/" + f.Name()
log.Noticef("registering partial: %s", pFile)
pContent, err := ioutil.ReadFile(pFile)
if err != nil {
log.Panicf("could not read partial '%s': %s", pFile, err)
}
raymond.RegisterPartial(f.Name(), string(pContent))
}
}
} else {
log.Panicf("could not read from partials directory '%s': %s", partialsPath, err)
}
} else if err == nil {
log.Panicf("template partials directory '%s' is not a directory", partialsPath)
} else {
log.Panicf("unknown error on partials directory '%s': %s", partialsPath, err)
}
}
processContent(contentConfig)
processAssets()