summaryrefslogtreecommitdiffstats
path: root/docs/content
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2018-12-23 19:43:17 +0100
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2018-12-23 19:43:17 +0100
commit2efc1a64c391420b1007f6e94b6ff616fb136635 (patch)
tree975cdabf173eeb0f35496aa89a46e6da52d7e65a /docs/content
parent25ddbb09fea7794edbbafa2ffce4e361cdc9bacf (diff)
docs: Document transform.Unmarshal
Fixes #5556
Diffstat (limited to 'docs/content')
-rw-r--r--docs/content/en/functions/transform.Unmarshal.md50
1 files changed, 50 insertions, 0 deletions
diff --git a/docs/content/en/functions/transform.Unmarshal.md b/docs/content/en/functions/transform.Unmarshal.md
new file mode 100644
index 000000000..0220de5d5
--- /dev/null
+++ b/docs/content/en/functions/transform.Unmarshal.md
@@ -0,0 +1,50 @@
+---
+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 and CSV."
+date: 2018-12-23
+categories: [functions]
+menu:
+ docs:
+ parent: "functions"
+keywords: []
+signature: ["RESOURCE or STRING | transform.Unmarshal [OPTIONS]" ]
+hugoversion: "0.53"
+aliases: []
+---
+
+
+The function accept 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:
+
+```go-html-template
+{{ $greetings := "hello = \"Hello Hugo\"" | transform.Unmarshal }}`
+```
+
+```go-html-template
+{{ $greetings := "hello = \"Hello Hugo\"" | resources.FromString "data/greetings.toml" | transform.Unmarshal }}
+```
+
+In both the above examples, you get a map you can work with:
+
+```go-html-template
+{{ $greetings.hello }}
+```
+
+The above prints `Hello Hugo`.
+
+## CSV Options
+
+Unmarshal with CSV as input has some options you can set:
+
+comma
+: The delmiter used, default is `,`
+
+comment
+: The comment character ued in the CSV. If set, lines beginning with the comment character without preceding whitespace are ignored.:
+
+
+Example:
+
+```go-html-template
+{{ $csv := "a;b;c" | transform.Unmarshal (dict "comma" ";") }}
+```
+