diff options
| author | Dave Henderson <dhenderson@gmail.com> | 2017-05-12 10:04:36 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2017-05-12 10:04:36 -0400 |
| commit | 8d5f38e2b0bab1117e82ddc6558ae5844e283496 (patch) | |
| tree | ac470906d012520bb9f1e574a44521c0447ed1cf /README.md | |
| parent | ebb865e7d178ff5d09a6bd748b86b03c6ee59b5f (diff) | |
| parent | 617e2e9df2aed6c17a4eee7b3b963a2388a1ec11 (diff) | |
Merge pull request #139 from hairyhenderson/indent-func
Adding new indent function
Diffstat (limited to 'README.md')
| -rw-r--r-- | README.md | 22 |
1 files changed, 22 insertions, 0 deletions
@@ -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. |
