mirror of
https://github.com/gohugoio/hugo.git
synced 2025-09-02 22:52:51 +02:00
Add js.Batch
Fixes #12626 Closes #7499 Closes #9978 Closes #12879 Closes #13113 Fixes #13116
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
{{ range $i, $e := .Scripts -}}
|
||||
{{ printf "import { %s as Script%d } from %q;" .Export $i .Import }}
|
||||
{{ end -}}
|
||||
{{ range $i, $e := .Runners }}
|
||||
{{ printf "import { %s as Run%d } from %q;" .Export $i .Import }}
|
||||
{{ end }}
|
||||
{{/* */}}
|
||||
let scripts = [];
|
||||
{{ range $i, $e := .Scripts -}}
|
||||
scripts.push({{ .RunnerJSON $i }});
|
||||
{{ end -}}
|
||||
{{/* */}}
|
||||
{{ range $i, $e := .Runners }}
|
||||
{{ $id := printf "Run%d" $i }}
|
||||
{{ $id }}(scripts);
|
||||
{{ end }}
|
@@ -695,13 +695,13 @@ func (t *templateHandler) applyBaseTemplate(overlay, base templateInfo) (tpl.Tem
|
||||
if !base.IsZero() {
|
||||
templ, err = templ.Parse(base.template)
|
||||
if err != nil {
|
||||
return nil, base.errWithFileContext("parse failed", err)
|
||||
return nil, base.errWithFileContext("text: base: parse failed", err)
|
||||
}
|
||||
}
|
||||
|
||||
templ, err = texttemplate.Must(templ.Clone()).Parse(overlay.template)
|
||||
if err != nil {
|
||||
return nil, overlay.errWithFileContext("parse failed", err)
|
||||
return nil, overlay.errWithFileContext("text: overlay: parse failed", err)
|
||||
}
|
||||
|
||||
// The extra lookup is a workaround, see
|
||||
@@ -720,13 +720,13 @@ func (t *templateHandler) applyBaseTemplate(overlay, base templateInfo) (tpl.Tem
|
||||
if !base.IsZero() {
|
||||
templ, err = templ.Parse(base.template)
|
||||
if err != nil {
|
||||
return nil, base.errWithFileContext("parse failed", err)
|
||||
return nil, base.errWithFileContext("html: base: parse failed", err)
|
||||
}
|
||||
}
|
||||
|
||||
templ, err = htmltemplate.Must(templ.Clone()).Parse(overlay.template)
|
||||
if err != nil {
|
||||
return nil, overlay.errWithFileContext("parse failed", err)
|
||||
return nil, overlay.errWithFileContext("html: overlay: parse failed", err)
|
||||
}
|
||||
|
||||
// The extra lookup is a workaround, see
|
||||
|
@@ -251,6 +251,9 @@ func newTemplateExecuter(d *deps.Deps) (texttemplate.Executer, map[string]reflec
|
||||
}
|
||||
|
||||
func createFuncMap(d *deps.Deps) map[string]any {
|
||||
if d.TmplFuncMap != nil {
|
||||
return d.TmplFuncMap
|
||||
}
|
||||
funcMap := template.FuncMap{}
|
||||
|
||||
nsMap := make(map[string]any)
|
||||
@@ -292,5 +295,7 @@ func createFuncMap(d *deps.Deps) map[string]any {
|
||||
}
|
||||
}
|
||||
|
||||
return funcMap
|
||||
d.TmplFuncMap = funcMap
|
||||
|
||||
return d.TmplFuncMap
|
||||
}
|
||||
|
Reference in New Issue
Block a user