Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/gohugoio/hugo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2020-05-23 16:32:27 +0300
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2020-05-23 23:00:34 +0300
commit6c3c6686f5d3c7155e2d455b07ac8ab70f42cb88 (patch)
tree666c09383480c74ba69ea7a0442a67029b83a095 /scripts/fork_go_templates
parentc34bf48560c91c8a2fa106867af7b08a569609b5 (diff)
Fix Go template script escaping
Fixes #6695
Diffstat (limited to 'scripts/fork_go_templates')
-rw-r--r--scripts/fork_go_templates/main.go15
1 files changed, 14 insertions, 1 deletions
diff --git a/scripts/fork_go_templates/main.go b/scripts/fork_go_templates/main.go
index d9d056797..04202b254 100644
--- a/scripts/fork_go_templates/main.go
+++ b/scripts/fork_go_templates/main.go
@@ -17,7 +17,7 @@ import (
func main() {
// TODO(bep) git checkout tag
- // The current is built with Go version 9341fe073e6f7742c9d61982084874560dac2014 / go1.13.5
+ // The current is built with Go version b68fa57c599720d33a2d735782969ce95eabf794 / go1.15dev
fmt.Println("Forking ...")
defer fmt.Println("Done ...")
@@ -55,6 +55,8 @@ var (
textTemplateReplacers = strings.NewReplacer(
`"text/template/`, `"github.com/gohugoio/hugo/tpl/internal/go_templates/texttemplate/`,
`"internal/fmtsort"`, `"github.com/gohugoio/hugo/tpl/internal/go_templates/fmtsort"`,
+ `"internal/testenv"`, `"github.com/gohugoio/hugo/tpl/internal/go_templates/testenv"`,
+ "TestLinkerGC", "_TestLinkerGC",
// Rename types and function that we want to overload.
"type state struct", "type stateOld struct",
"func (s *state) evalFunction", "func (s *state) evalFunctionOld",
@@ -63,6 +65,10 @@ var (
"func isTrue(val reflect.Value) (truth, ok bool) {", "func isTrueOld(val reflect.Value) (truth, ok bool) {",
)
+ testEnvReplacers = strings.NewReplacer(
+ `"internal/cfg"`, `"github.com/gohugoio/hugo/tpl/internal/go_templates/cfg"`,
+ )
+
htmlTemplateReplacers = strings.NewReplacer(
`. "html/template"`, `. "github.com/gohugoio/hugo/tpl/internal/go_templates/htmltemplate"`,
`"html/template"`, `template "github.com/gohugoio/hugo/tpl/internal/go_templates/htmltemplate"`,
@@ -116,6 +122,13 @@ var goPackages = []goPackage{
goPackage{srcPkg: "internal/fmtsort", dstPkg: "fmtsort", rewriter: func(name string) {
rewrite(name, `"internal/fmtsort" -> "github.com/gohugoio/hugo/tpl/internal/go_templates/fmtsort"`)
}},
+ goPackage{srcPkg: "internal/testenv", dstPkg: "testenv",
+ replacer: func(name, content string) string { return testEnvReplacers.Replace(content) }, rewriter: func(name string) {
+ rewrite(name, `"internal/testenv" -> "github.com/gohugoio/hugo/tpl/internal/go_templates/testenv"`)
+ }},
+ goPackage{srcPkg: "internal/cfg", dstPkg: "cfg", rewriter: func(name string) {
+ rewrite(name, `"internal/cfg" -> "github.com/gohugoio/hugo/tpl/internal/go_templates/cfg"`)
+ }},
}
var fs = afero.NewOsFs()