summaryrefslogtreecommitdiff
path: root/README.md
diff options
context:
space:
mode:
authorDave Henderson <dhenderson@gmail.com>2017-05-12 09:13:16 -0400
committerGitHub <noreply@github.com>2017-05-12 09:13:16 -0400
commitebb865e7d178ff5d09a6bd748b86b03c6ee59b5f (patch)
tree4085e0acd6503647aaebae57f36221fbfa5ab66b /README.md
parent6695b9987b007feb58024418242cb7a9da8ba663 (diff)
parent527628ab6f5180f8a2dbd527513a12f128628523 (diff)
Merge pull request #137 from hairyhenderson/tojsonpretty-func
Adding new toJSONPretty function
Diffstat (limited to 'README.md')
-rw-r--r--README.md21
1 files changed, 21 insertions, 0 deletions
diff --git a/README.md b/README.md
index a37380f8..39a60bcf 100644
--- a/README.md
+++ b/README.md
@@ -57,6 +57,7 @@ Gomplate is an alternative that will let you process templates which also includ
- [`yaml`](#yaml)
- [`yamlArray`](#yamlarray)
- [`toJSON`](#tojson)
+ - [`toJSONPretty`](#tojsonpretty)
- [`toYAML`](#toyaml)
- [`datasource`](#datasource)
- [`datasourceExists`](#datasourceexists)
@@ -544,6 +545,26 @@ $ gomplate < input.tmpl
{"hello":"world"}
```
+#### `toJSONPretty`
+
+Converts an object to a pretty-printed (or _indented_) JSON document. Input objects may be the result of `json`, `yaml`, `jsonArray`, or `yamlArray` functions, or they could be provided by a `datasource`.
+
+The indent string must be provided as an argument.
+
+##### Example
+
+_`input.tmpl`:_
+```
+{{ `{"hello":"world"}` | json | toJSONPretty " " }}
+```
+
+```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`.