summaryrefslogtreecommitdiff
path: root/README.md
diff options
context:
space:
mode:
authorDave Henderson <dhenderson@gmail.com>2017-05-12 09:11:52 -0400
committerDave Henderson <dhenderson@gmail.com>2017-05-12 09:16:01 -0400
commit617e2e9df2aed6c17a4eee7b3b963a2388a1ec11 (patch)
treeac470906d012520bb9f1e574a44521c0447ed1cf /README.md
parentebb865e7d178ff5d09a6bd748b86b03c6ee59b5f (diff)
Adding new indent function
Signed-off-by: Dave Henderson <dhenderson@gmail.com>
Diffstat (limited to 'README.md')
-rw-r--r--README.md22
1 files changed, 22 insertions, 0 deletions
diff --git a/README.md b/README.md
index 39a60bcf..92b8085f 100644
--- a/README.md
+++ b/README.md
@@ -52,6 +52,7 @@ Gomplate is an alternative that will let you process templates which also includ
- [`trim`](#trim)
- [`urlParse`](#urlparse)
- [`has`](#has)
+ - [`indent`](#indent)
- [`json`](#json)
- [`jsonArray`](#jsonarray)
- [`yaml`](#yaml)
@@ -459,6 +460,27 @@ $ gomplate -d vault:///secret/foo < input.tmpl
The secret is 'foo: bar'
```
+#### `indent`
+
+Indents a given string with the given indentation pattern. If the input string has multiple lines, each line will be indented.
+
+##### Example
+
+This function can be especially useful when adding YAML snippets into other YAML documents, where indentation is important:
+
+_`input.tmpl`:_
+```
+foo:
+{{ `{"bar": {"baz": 2}}` | json | toYAML | indent " " }}
+```
+
+```console
+$ gomplate -f input.tmpl
+foo:
+ bar:
+ baz: 2
+```
+
#### `json`
Converts a JSON string into an object. Only works for JSON Objects (not Arrays or other valid JSON types). This can be used to access properties of JSON objects.