summaryrefslogtreecommitdiffstats
path: root/tpl
diff options
context:
space:
mode:
authorCameron Moore <moorereason@gmail.com>2021-01-16 23:05:58 -0600
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2021-01-22 19:25:45 +0100
commit241b7483ea954653512d4895ad6bacf79ee26ddc (patch)
treebc3952c96d955f625f25d243a7c7b09e86de6b29 /tpl
parente19a046c4be9b0654884259b9df94f41561e4fc3 (diff)
tpl: Fix race condition in text template baseof
Copy most of the htmltemplate cloning to the textemplate implementation in the same function.
Diffstat (limited to 'tpl')
-rw-r--r--tpl/tplimpl/template.go8
1 files changed, 7 insertions, 1 deletions
diff --git a/tpl/tplimpl/template.go b/tpl/tplimpl/template.go
index eb91ab837..60e3b7df9 100644
--- a/tpl/tplimpl/template.go
+++ b/tpl/tplimpl/template.go
@@ -598,10 +598,16 @@ func (t *templateHandler) applyBaseTemplate(overlay, base templateInfo) (tpl.Tem
}
}
- templ, err = templ.Parse(overlay.template)
+ templ, err = texttemplate.Must(templ.Clone()).Parse(overlay.template)
if err != nil {
return nil, overlay.errWithFileContext("parse failed", err)
}
+
+ // The extra lookup is a workaround, see
+ // * https://github.com/golang/go/issues/16101
+ // * https://github.com/gohugoio/hugo/issues/2549
+ // templ = templ.Lookup(templ.Name())
+
return templ, nil
}