]> git.maquefel.me Git - brevno-suite/hugo/commitdiff
hugolib: Display correct markup identifier in error message
authorJoe Mooring <joe.mooring@veriphor.com>
Sat, 7 Oct 2023 18:11:45 +0000 (11:11 -0700)
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Mon, 30 Oct 2023 08:01:34 +0000 (09:01 +0100)
Fixes #11538

hugolib/integration_test.go
hugolib/page__meta.go

index 417fe212993b1de71b60552f77a0a77a446be02a..1109694b1f5b3f40bc0bdacaedff4c4ef8c02281 100644 (file)
@@ -14,6 +14,7 @@
 package hugolib_test
 
 import (
+       "strings"
        "testing"
 
        "github.com/gohugoio/hugo/hugolib"
@@ -87,3 +88,29 @@ tags: ['T1']
        )
 
 }
+
+// Issue #11538
+func TestRenderStringBadMarkupOpt(t *testing.T) {
+       t.Parallel()
+
+       files := `
+-- layouts/index.html --
+{{ $opts := dict "markup" "foo" }}
+{{ "something" | .RenderString $opts }}
+       `
+
+       b := hugolib.NewIntegrationTestBuilder(
+               hugolib.IntegrationTestConfig{
+                       T:           t,
+                       TxtarString: files,
+               },
+       )
+
+       _, err := b.BuildE()
+
+       want := `no content renderer found for markup "foo"`
+       if !strings.Contains(err.Error(), want) {
+               t.Errorf("error msg must contain %q, error msg actually contains %q", want, err.Error())
+       }
+
+}
index 0dd2369045fc5aa65f4fbd1948ad16c1b83bb671..3781a847ad000f6a4e143cbe0fade1f902e87a93 100644 (file)
@@ -731,7 +731,7 @@ func (p *pageMeta) newContentConverter(ps *pageState, markup string) (converter.
        }
        cp := p.s.ContentSpec.Converters.Get(markup)
        if cp == nil {
-               return converter.NopConverter, fmt.Errorf("no content renderer found for markup %q", p.markup)
+               return converter.NopConverter, fmt.Errorf("no content renderer found for markup %q", markup)
        }
 
        var id string