github.com/olliephillips/hugo@v0.42.2/hugolib/page_without_content.go (about) 1 // Copyright 2018 The Hugo Authors. All rights reserved. 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // http://www.apache.org/licenses/LICENSE-2.0 7 // 8 // Unless required by applicable law or agreed to in writing, software 9 // distributed under the License is distributed on an "AS IS" BASIS, 10 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 // See the License for the specific language governing permissions and 12 // limitations under the License. 13 14 package hugolib 15 16 import ( 17 "html/template" 18 ) 19 20 // PageWithoutContent is sent to the shortcodes. They cannot access the content 21 // they're a part of. It would cause an infinite regress. 22 // 23 // Go doesn't support virtual methods, so this careful dance is currently (I think) 24 // the best we can do. 25 type PageWithoutContent struct { 26 *Page 27 } 28 29 // Content returns an empty string. 30 func (p *PageWithoutContent) Content() (interface{}, error) { 31 return "", nil 32 } 33 34 // Truncated always returns false. 35 func (p *PageWithoutContent) Truncated() bool { 36 return false 37 } 38 39 // Summary returns an empty string. 40 func (p *PageWithoutContent) Summary() template.HTML { 41 return "" 42 } 43 44 // WordCount always returns 0. 45 func (p *PageWithoutContent) WordCount() int { 46 return 0 47 } 48 49 // ReadingTime always returns 0. 50 func (p *PageWithoutContent) ReadingTime() int { 51 return 0 52 } 53 54 // FuzzyWordCount always returns 0. 55 func (p *PageWithoutContent) FuzzyWordCount() int { 56 return 0 57 } 58 59 // Plain returns an empty string. 60 func (p *PageWithoutContent) Plain() string { 61 return "" 62 } 63 64 // PlainWords returns an empty string slice. 65 func (p *PageWithoutContent) PlainWords() []string { 66 return []string{} 67 }