summaryrefslogtreecommitdiffstats
path: root/hugolib/page_output.go
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2017-03-06 19:16:31 +0100
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2017-03-27 15:43:56 +0200
commit348834d0176611fc0a08121b86c40e37644a89e3 (patch)
treeab42194a96b05d93229c687b1dd5bb9fe572fc0b /hugolib/page_output.go
parent254cd89c8e50f46bb733cc170a79e9d3089ae5a8 (diff)
hugolib: Add a PageOutput wrapper for rendering
Diffstat (limited to 'hugolib/page_output.go')
-rw-r--r--hugolib/page_output.go40
1 files changed, 40 insertions, 0 deletions
diff --git a/hugolib/page_output.go b/hugolib/page_output.go
new file mode 100644
index 000000000..79b7ead9a
--- /dev/null
+++ b/hugolib/page_output.go
@@ -0,0 +1,40 @@
+// Copyright 2017 The Hugo Authors. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package hugolib
+
+import (
+ "github.com/spf13/hugo/output"
+)
+
+// PageOutput represents one of potentially many output formats of a given
+// Page.
+type PageOutput struct {
+ *Page
+
+ outputType output.Type
+}
+
+func newPageOutput(p *Page, outputType output.Type) *PageOutput {
+ // TODO(bep) output avoid copy of first?
+ p = p.copy()
+ return &PageOutput{Page: p, outputType: outputType}
+}
+
+// copy creates a copy of this PageOutput with the lazy sync.Once vars reset
+// so they will be evaluated again, for word count calculations etc.
+func (p *PageOutput) copy() *PageOutput {
+ c := *p
+ c.Page = p.Page.copy()
+ return &c
+}