summaryrefslogtreecommitdiff
path: root/README.md
diff options
context:
space:
mode:
authorDave Henderson <dhenderson@gmail.com>2017-03-06 16:41:28 -0500
committerDave Henderson <dhenderson@gmail.com>2017-03-06 20:08:33 -0500
commit7b6434d5784b811d4a3e5b663cfacd2716bd7db9 (patch)
tree1a557a2e158e78f60f8750d7ba220d3a3231354f /README.md
parent198c1145bdf4ee94342f0c282f8294561e0419c0 (diff)
Adding toJSON and toYAML functions
Signed-off-by: Dave Henderson <dhenderson@gmail.com>
Diffstat (limited to 'README.md')
-rw-r--r--README.md43
1 files changed, 42 insertions, 1 deletions
diff --git a/README.md b/README.md
index de764588..6969686b 100644
--- a/README.md
+++ b/README.md
@@ -67,6 +67,10 @@ Gomplate is an alternative that will let you process templates which also includ
- [Example](#example)
- [`yamlArray`](#yamlarray)
- [Example](#example)
+ - [`toJSON`](#tojson)
+ - [Example](#example)
+ - [`toYAML`](#toyaml)
+ - [Example](#example)
- [`datasource`](#datasource)
- [Examples](#examples)
- [Basic usage](#basic-usage)
@@ -111,7 +115,7 @@ $ apk add gomplate
...
```
-_Note: the Alpine version of gomplate may lag behind the latest release of gomplate._
+_Note: the Alpine version of gomplate may lag behind the latest release of gomplate._
### use with Docker
@@ -453,6 +457,43 @@ $ gomplate < input.tmpl
Hello world
```
+#### `toJSON`
+
+Converts an object to a JSON document. Input objects may be the result of `json`, `yaml`, `jsonArray`, or `yamlArray` functions, or they could be provided by a `datasource`.
+
+##### Example
+
+_This is obviously contrived - `json` is used to create an object._
+
+_`input.tmpl`:_
+```
+{{ (`{"foo":{"hello":"world"}}` | json).foo | toJSON }}
+```
+
+```console
+$ gomplate < input.tmpl
+{"hello":"world"}
+```
+
+#### `toYAML`
+
+Converts an object to a YAML document. Input objects may be the result of `json`, `yaml`, `jsonArray`, or `yamlArray` functions, or they could be provided by a `datasource`.
+
+##### Example
+
+_This is obviously contrived - `json` is used to create an object._
+
+_`input.tmpl`:_
+```
+{{ (`{"foo":{"hello":"world"}}` | json).foo | toYAML }}
+```
+
+```console
+$ gomplate < input.tmpl
+hello: world
+
+```
+
#### `datasource`
Parses a given datasource (provided by the [`--datasource/-d`](#--datasource-d) argument).