mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-21 21:35:28 +02:00
Throw error if resources.PostProcess is used in a deferred template
That just doesn't work. See #12655
This commit is contained in:
@@ -200,3 +200,23 @@ func TestDeferFromContentAdapterShouldFail(t *testing.T) {
|
||||
b.Assert(err, qt.Not(qt.IsNil))
|
||||
b.Assert(err.Error(), qt.Contains, "error calling Defer: this method cannot be called before the site is fully initialized")
|
||||
}
|
||||
|
||||
func TestDeferPostProcessShouldThrowAnError(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
files := `
|
||||
-- hugo.toml --
|
||||
-- assets/mytext.txt --
|
||||
ABCD.
|
||||
-- layouts/index.html --
|
||||
Home
|
||||
{{ with (templates.Defer (dict "key" "foo")) }}
|
||||
{{ $mytext := resources.Get "mytext.txt" | minify | resources.PostProcess }}
|
||||
{{ end }}
|
||||
|
||||
`
|
||||
b, err := hugolib.TestE(t, files)
|
||||
|
||||
b.Assert(err, qt.Not(qt.IsNil))
|
||||
b.Assert(err.Error(), qt.Contains, "resources.PostProcess cannot be used in a deferred template")
|
||||
}
|
||||
|
Reference in New Issue
Block a user