mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-22 21:42:50 +02:00
Merge commit 'f96384a3b596f9bc0a3a035970b09b2c601f0ccb'
This commit is contained in:
@@ -1,15 +1,12 @@
|
||||
---
|
||||
title: "transform.Unmarshal"
|
||||
title: transform.Unmarshal
|
||||
description: "`transform.Unmarshal` (alias `unmarshal`) parses the input and converts it into a map or an array. Supported formats are JSON, TOML, YAML, XML and CSV."
|
||||
date: 2018-12-23
|
||||
categories: [functions]
|
||||
menu:
|
||||
docs:
|
||||
parent: "functions"
|
||||
parent: functions
|
||||
keywords: []
|
||||
signature: ["RESOURCE or STRING | transform.Unmarshal [OPTIONS]"]
|
||||
hugoversion: "0.53"
|
||||
aliases: []
|
||||
---
|
||||
|
||||
The function accepts either a `Resource` created in [Hugo Pipes](/hugo-pipes/) or via [Page Bundles](/content-management/page-bundles/), or simply a string. The two examples below will produce the same map:
|
||||
@@ -52,7 +49,7 @@ As a convenience, Hugo allows you to access XML data in the same way that you ac
|
||||
|
||||
To get the contents of `<title>` in the document below, you use `{{ .message.title }}`:
|
||||
|
||||
```
|
||||
```xml
|
||||
<root>
|
||||
<message>
|
||||
<title>Hugo rocks!</title>
|
||||
@@ -63,7 +60,7 @@ To get the contents of `<title>` in the document below, you use `{{ .message.tit
|
||||
|
||||
The following example lists the items of an RSS feed:
|
||||
|
||||
```
|
||||
```go-html-template
|
||||
{{ with resources.Get "https://example.com/rss.xml" | transform.Unmarshal }}
|
||||
{{ range .channel.item }}
|
||||
<strong>{{ .title | plainify | htmlUnescape }}</strong><br />
|
||||
|
Reference in New Issue
Block a user