aboutsummaryrefslogtreecommitdiffhomepage
path: root/parser/frontmatter.go
diff options
context:
space:
mode:
authorPaul van Brouwershaven <[email protected]>2021-12-02 17:30:36 +0100
committerGitHub <[email protected]>2021-12-02 17:30:36 +0100
commit0eaaa8fee37068bfc8ecfb760f770ecc9a7af22a (patch)
tree95cf7c5ac3a7e56c0eb411a28cae5c0412a510bd /parser/frontmatter.go
parent58adbeef88ea5c8769d12ba27eef2d89bdf575eb (diff)
downloadhugo-0eaaa8fee37068bfc8ecfb760f770ecc9a7af22a.tar.gz
hugo-0eaaa8fee37068bfc8ecfb760f770ecc9a7af22a.zip
Implement XML data support
Example: ``` {{ with resources.Get "https://example.com/rss.xml" | transform.Unmarshal }} {{ range .channel.item }} <strong>{{ .title | plainify | htmlUnescape }}</strong><br /> <p>{{ .description | plainify | htmlUnescape }}</p> {{ $link := .link | plainify | htmlUnescape }} <a href="{{ $link }}">{{ $link }}</a><br /> <hr> {{ end }} {{ end }} ``` Closes #4470
Diffstat (limited to 'parser/frontmatter.go')
-rw-r--r--parser/frontmatter.go9
1 files changed, 9 insertions, 0 deletions
diff --git a/parser/frontmatter.go b/parser/frontmatter.go
index 79701a0fc..a99829521 100644
--- a/parser/frontmatter.go
+++ b/parser/frontmatter.go
@@ -23,6 +23,8 @@ import (
toml "github.com/pelletier/go-toml/v2"
yaml "gopkg.in/yaml.v2"
+
+ xml "github.com/clbanning/mxj/v2"
)
const (
@@ -62,7 +64,14 @@ func InterfaceToConfig(in interface{}, format metadecoders.Format, w io.Writer)
_, err = w.Write([]byte{'\n'})
return err
+ case metadecoders.XML:
+ b, err := xml.AnyXmlIndent(in, "", "\t", "root")
+ if err != nil {
+ return err
+ }
+ _, err = w.Write(b)
+ return err
default:
return errors.New("unsupported Format provided")
}