summaryrefslogtreecommitdiffstats
path: root/output/layout.go
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2017-03-26 19:34:30 +0200
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2017-03-27 15:43:56 +0200
commit930a3df1b79d21f005a63918b89cc01ae5a4cd9e (patch)
tree07955b204d91ee67857beb1af2a6d49da4386086 /output/layout.go
parente49a2b83ad9825a978ecbf0ff5fd9b7331690c17 (diff)
hugolib, output: Restrict Render to regular Pages
Using it for list pages doesn't work and has potential weird side-effects. The user probably meant to range over .Site.ReqularPages, and that is now marked clearly in the log.
Diffstat (limited to 'output/layout.go')
-rw-r--r--output/layout.go14
1 files changed, 9 insertions, 5 deletions
diff --git a/output/layout.go b/output/layout.go
index cda6eb8a0..a2bfd7717 100644
--- a/output/layout.go
+++ b/output/layout.go
@@ -83,19 +83,23 @@ indexes/indexes.NAME.SUFFIX indexes/indexes.SUFFIX
`
)
-func (l *LayoutHandler) For(d LayoutDescriptor, layoutOverride string, f Format) []string {
+func (l *LayoutHandler) For(d LayoutDescriptor, layoutOverride string, f Format) ([]string, error) {
// We will get lots of requests for the same layouts, so avoid recalculations.
key := layoutCacheKey{d, layoutOverride, f}
l.mu.RLock()
if cacheVal, found := l.cache[key]; found {
l.mu.RUnlock()
- return cacheVal
+ return cacheVal, nil
}
l.mu.RUnlock()
var layouts []string
+ if layoutOverride != "" && d.Kind != "page" {
+ return layouts, fmt.Errorf("Custom layout (%q) only supported for regular pages, not kind %q", layoutOverride, d.Kind)
+ }
+
layout := d.Layout
if layoutOverride != "" {
@@ -106,7 +110,7 @@ func (l *LayoutHandler) For(d LayoutDescriptor, layoutOverride string, f Format)
if d.Kind == "page" {
if isRSS {
- return []string{}
+ return []string{}, nil
}
layouts = regularPageLayouts(d.Type, layout, f)
} else {
@@ -148,14 +152,14 @@ func (l *LayoutHandler) For(d LayoutDescriptor, layoutOverride string, f Format)
}
}
- return layoutsWithThemeLayouts
+ return layoutsWithThemeLayouts, nil
}
l.mu.Lock()
l.cache[key] = layouts
l.mu.Unlock()
- return layouts
+ return layouts, nil
}
func resolveListTemplate(d LayoutDescriptor, f Format,