-- hugo.toml --
disableKinds = ['page','rss','section','sitemap','taxonomy','term']
-- layouts/index.html --
-{{ $macros := dict
+{{ $macros := dict
"\\addBar" "\\bar{#1}"
"\\bold" "\\mathbf{#1}"
}}
<mi>y</mi>
`)
}
+
+// Issue #12977
+func TestUnmarshalWithIndentedYAML(t *testing.T) {
+ t.Parallel()
+
+ files := `
+-- hugo.toml --
+disableKinds = ['page','rss','section','sitemap','taxonomy','term']
+-- layouts/index.html --
+{{ $yaml := "\n a:\n b: 1\n c:\n d: 2\n" }}
+{{ $yaml | transform.Unmarshal | encoding.Jsonify }}
+`
+
+ b := hugolib.Test(t, files)
+
+ b.AssertFileExists("public/index.html", true)
+ b.AssertFileContent("public/index.html", `{"a":{"b":1},"c":{"d":2}}`)
+}
if err != nil {
return nil, fmt.Errorf("type %T not supported", data)
}
- dataStr = strings.TrimSpace(dataStr)
- if dataStr == "" {
+ if strings.TrimSpace(dataStr) == "" {
return nil, nil
}