From 527628ab6f5180f8a2dbd527513a12f128628523 Mon Sep 17 00:00:00 2001 From: Dave Henderson Date: Thu, 11 May 2017 21:43:21 -0400 Subject: Adding new toJSONPretty function Signed-off-by: Dave Henderson --- README.md | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'README.md') 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`. -- cgit v1.2.3