Skip to content

Commit

Permalink
hugolib: Display correct markup identifier in error message
Browse files Browse the repository at this point in the history
Fixes #11538
  • Loading branch information
jmooring authored and bep committed Oct 30, 2023
1 parent 8f60c0c commit a2488b1
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
27 changes: 27 additions & 0 deletions hugolib/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
package hugolib_test

import (
"strings"
"testing"

"github.com/gohugoio/hugo/hugolib"
Expand Down Expand Up @@ -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())
}

}
2 changes: 1 addition & 1 deletion hugolib/page__meta.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit a2488b1

Please sign in to comment.