partials handling
This commit is contained in:
27
main.go
27
main.go
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user