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
path: root/tpl
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2021-07-27 20:07:10 +0300
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2021-07-28 12:51:13 +0300
commita3701e09313695d4a0f6fb0eb7844c1a4befc07a (patch)
tree443c85a8b6cbf841155efad4aa99ead8c2824720 /tpl
parent40b6016cf3f7aac541b042d32e3a162411fd9cd0 (diff)
Switch to go-toml v2
We have been using `go-toml` for language files only. This commit makes it the only TOML library. It's spec compliant and very fast. A benchark building a site with 200 pages with TOML front matter: ```bash name old time/op new time/op delta SiteNew/Regular_TOML_front_matter-16 48.5ms ± 1% 47.1ms ± 1% -2.85% (p=0.029 n=4+4) name old alloc/op new alloc/op delta SiteNew/Regular_TOML_front_matter-16 16.9MB ± 0% 16.7MB ± 0% -1.56% (p=0.029 n=4+4) name old allocs/op new allocs/op delta SiteNew/Regular_TOML_front_matter-16 302k ± 0% 296k ± 0% -2.20% (p=0.029 n=4+4) ``` Note that the front matter unmarshaling is only a small part of building a site, so the above is very good. Fixes #8801
Diffstat (limited to 'tpl')
-rw-r--r--tpl/transform/remarshal_test.go26
1 files changed, 12 insertions, 14 deletions
diff --git a/tpl/transform/remarshal_test.go b/tpl/transform/remarshal_test.go
index 9f3e05e61..c34122a2a 100644
--- a/tpl/transform/remarshal_test.go
+++ b/tpl/transform/remarshal_test.go
@@ -30,20 +30,20 @@ func TestRemarshal(t *testing.T) {
ns := New(newDeps(v))
c := qt.New(t)
- tomlExample := `title = "Test Metadata"
+ tomlExample := `title = 'Test Metadata'
[[resources]]
- src = "**image-4.png"
- title = "The Fourth Image!"
+ src = '**image-4.png'
+ title = 'The Fourth Image!'
[resources.params]
- byline = "picasso"
+ byline = 'picasso'
[[resources]]
- name = "my-cool-image-:counter"
- src = "**.png"
- title = "TOML: The Image #:counter"
+ name = 'my-cool-image-:counter'
+ src = '**.png'
+ title = 'TOML: The Image #:counter'
[resources.params]
- byline = "bep"
+ byline = 'bep'
`
yamlExample := `resources:
@@ -129,11 +129,9 @@ a = "b"
`
- expected := `
-Hugo = "Rules"
-
+ expected := `Hugo = 'Rules'
[m]
- a = "b"
+a = 'b'
`
for _, format := range []string{"json", "yaml", "toml"} {
@@ -149,7 +147,7 @@ Hugo = "Rules"
diff := htesting.DiffStrings(expected, converted)
if len(diff) > 0 {
- t.Fatalf("[%s] Expected \n%v\ngot\n%v\ndiff:\n%v\n", fromTo, expected, converted, diff)
+ t.Fatalf("[%s] Expected \n%v\ngot\n>>%v\ndiff:\n%v\n", fromTo, expected, converted, diff)
}
}
}
@@ -182,5 +180,5 @@ func TestTestRemarshalMapInput(t *testing.T) {
output, err := ns.Remarshal("toml", input)
c.Assert(err, qt.IsNil)
- c.Assert(output, qt.Equals, "hello = \"world\"\n")
+ c.Assert(output, qt.Equals, "hello = 'world'\n")
}