From 617e2e9df2aed6c17a4eee7b3b963a2388a1ec11 Mon Sep 17 00:00:00 2001 From: Dave Henderson Date: Fri, 12 May 2017 09:11:52 -0400 Subject: Adding new indent function Signed-off-by: Dave Henderson --- README.md | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'README.md') 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. -- cgit v1.2.3