diff options
author | Paul van Brouwershaven <vanbroup@users.noreply.github.com> | 2021-12-02 17:30:36 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-12-02 17:30:36 +0100 |
commit | 0eaaa8fee37068bfc8ecfb760f770ecc9a7af22a (patch) | |
tree | 95cf7c5ac3a7e56c0eb411a28cae5c0412a510bd /hugolib/resource_chain_test.go | |
parent | 58adbeef88ea5c8769d12ba27eef2d89bdf575eb (diff) |
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 'hugolib/resource_chain_test.go')
-rw-r--r-- | hugolib/resource_chain_test.go | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/hugolib/resource_chain_test.go b/hugolib/resource_chain_test.go index 0a997cda3..05e8a9d00 100644 --- a/hugolib/resource_chain_test.go +++ b/hugolib/resource_chain_test.go @@ -591,9 +591,9 @@ func TestResourceChains(t *testing.T) { case "/mydata/xml1.xml": w.Write([]byte(` - <hello> - <world>Hugo Rocks!</<world> - </hello>`)) + <hello> + <world>Hugo Rocks!</<world> + </hello>`)) return case "/mydata/svg1.svg": @@ -872,16 +872,19 @@ Publish 2: {{ $cssPublish2.Permalink }} {{ $toml := "slogan = \"Hugo Rocks!\"" | resources.FromString "slogan.toml" | transform.Unmarshal }} {{ $csv1 := "\"Hugo Rocks\",\"Hugo is Fast!\"" | resources.FromString "slogans.csv" | transform.Unmarshal }} {{ $csv2 := "a;b;c" | transform.Unmarshal (dict "delimiter" ";") }} +{{ $xml := "<?xml version=\"1.0\" encoding=\"UTF-8\"?><note><to>You</to><from>Me</from><heading>Reminder</heading><body>Do not forget XML</body></note>" | transform.Unmarshal }} Slogan: {{ $toml.slogan }} CSV1: {{ $csv1 }} {{ len (index $csv1 0) }} CSV2: {{ $csv2 }} +XML: {{ $xml.body }} `) }, func(b *sitesBuilder) { b.AssertFileContent("public/index.html", `Slogan: Hugo Rocks!`, `[[Hugo Rocks Hugo is Fast!]] 2`, `CSV2: [[a b c]]`, + `XML: Do not forget XML`, ) }}, {"resources.Get", func() bool { return true }, func(b *sitesBuilder) { |