tpl/transform: Add transform.Unmarshal func

Fixes #5428
This commit is contained in:
Bjørn Erik Pedersen
2018-12-21 16:21:13 +01:00
parent 43f9df0194
commit 822dc627a1
20 changed files with 633 additions and 74 deletions

View File

@@ -339,6 +339,16 @@ Publish 2: {{ $cssPublish2.Permalink }}
assert.False(b.CheckExists("public/inline.min.css"), "Inline content should not be copied to /public")
}},
{"unmarshal", func() bool { return true }, func(b *sitesBuilder) {
b.WithTemplates("home.html", `
{{ $toml := "slogan = \"Hugo Rocks!\"" | resources.FromString "slogan.toml" | transform.Unmarshal }}
Slogan: {{ $toml.slogan }}
`)
}, func(b *sitesBuilder) {
b.AssertFileContent("public/index.html", `Slogan: Hugo Rocks!`)
}},
{"template", func() bool { return true }, func(b *sitesBuilder) {}, func(b *sitesBuilder) {
}},
}