mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-24 21:56:05 +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:
@@ -16,6 +16,7 @@ package tplimpl
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/gohugoio/hugo/helpers"
|
||||
htmltemplate "github.com/gohugoio/hugo/tpl/internal/go_templates/htmltemplate"
|
||||
@@ -248,7 +249,12 @@ func (c *templateContext) handleDefer(withNode *parse.WithNode) {
|
||||
n := l.Nodes[0].(*parse.ActionNode)
|
||||
|
||||
inner := withNode.List.CopyList()
|
||||
innerHash := helpers.MD5String(inner.String())
|
||||
s := inner.String()
|
||||
if strings.Contains(s, "resources.PostProcess") {
|
||||
c.err = errors.New("resources.PostProcess cannot be used in a deferred template")
|
||||
return
|
||||
}
|
||||
innerHash := helpers.MD5String(s)
|
||||
deferredID := tpl.HugoDeferredTemplatePrefix + innerHash
|
||||
|
||||
c.deferNodes[deferredID] = inner
|
||||
|
Reference in New Issue
Block a user