diff options
| author | Dave Henderson <dhenderson@gmail.com> | 2017-05-12 09:13:16 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2017-05-12 09:13:16 -0400 |
| commit | ebb865e7d178ff5d09a6bd748b86b03c6ee59b5f (patch) | |
| tree | 4085e0acd6503647aaebae57f36221fbfa5ab66b /README.md | |
| parent | 6695b9987b007feb58024418242cb7a9da8ba663 (diff) | |
| parent | 527628ab6f5180f8a2dbd527513a12f128628523 (diff) | |
Merge pull request #137 from hairyhenderson/tojsonpretty-func
Adding new toJSONPretty function
Diffstat (limited to 'README.md')
| -rw-r--r-- | README.md | 21 |
1 files changed, 21 insertions, 0 deletions
@@ -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`. |
