Enhance Page and Resource String()
authorVas Sudanagunta <vas@commonkarma.org>
Fri, 25 May 2018 23:59:58 +0000 (19:59 -0400)
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Sat, 26 May 2018 07:43:47 +0000 (09:43 +0200)
hugolib/page.go
resource/resource.go

index 7c2ac70b291d289748a8c75ce6336f3a9545fdcb..89d68084ed0e6f30237550f56d2fe9d6dc2a2d1c 100644 (file)
@@ -2013,7 +2013,11 @@ func (p *Page) RelRef(refs ...string) (string, error) {
 }
 
 func (p *Page) String() string {
+       if p.Path() != "" {
+               return fmt.Sprintf("Page(%s)", p.Path())
+       }
        return fmt.Sprintf("Page(%q)", p.title)
+
 }
 
 // Scratch returns the writable context associated with this Page.
index e92706803ee92b96b6664e35cbe842bb8cd7bc26..0714805e87305c755ea5b1344e56e4367335e3ff 100644 (file)
@@ -419,8 +419,6 @@ type genericResource struct {
        // The relative path to this resource.
        relTargetPath dirFile
 
-       file string
-
        // Base is set when the output format's path has a offset, e.g. for AMP.
        base string
 
@@ -554,6 +552,10 @@ func (l *genericResource) AbsSourceFilename() string {
        return l.sourceFilename
 }
 
+func (l *genericResource) String() string {
+       return fmt.Sprintf("Resource(%s: %s)", l.resourceType, l.name)
+}
+
 func (l *genericResource) Publish() error {
        f, err := l.sourceFs().Open(l.AbsSourceFilename())
        if err != nil {