Skip to content

Commit 3771e58

Browse files
authored
[docs] - toYaml / toYamlPretty (#1720)
* Updates the documentation adding a section for toYaml and toYamlPretty Signed-off-by: James Payne <[email protected]> * Update with consistent comma placement Signed-off-by: James Payne <[email protected]> * Update with trailing period Signed-off-by: James Payne <[email protected]> --------- Signed-off-by: James Payne <[email protected]>
1 parent f58b727 commit 3771e58

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

content/en/docs/chart_template_guide/function_list.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -701,6 +701,7 @@ The following type conversion functions are provided by Helm:
701701
- `fromJson`: Convert a JSON string to an object.
702702
- `fromJsonArray`: Convert a JSON array to a list.
703703
- `toYaml`: Convert list, slice, array, dict, or object to indented yaml, can be used to copy chunks of yaml from any source. This function is equivalent to GoLang yaml.Marshal function, see docs here: https://pkg.go.dev/gopkg.in/yaml.v2#Marshal
704+
- `toYamlPretty`: Convert list, slice, array, dict, or object to indented yaml. Equivalent to `toYaml` but will additionally indent lists by 2 spaces.
704705
- `toToml`: Convert list, slice, array, dict, or object to toml, can be used to copy chunks of toml from any source.
705706
- `fromYamlArray`: Convert a YAML array to a list.
706707

@@ -826,6 +827,32 @@ greeting: |
826827
{{ end }}
827828
```
828829

830+
### toYaml, toYamlPretty
831+
832+
The `toYaml` and `toYamlPretty` functions encode an object (list, slice, array, dict, or object) into an indented YAML string.
833+
834+
> Note that `toYamlPretty` is functionally equivalent but will output YAML with additional indents for list elements
835+
836+
```yaml
837+
# toYaml
838+
- name: bob
839+
age: 25
840+
hobbies:
841+
- hiking
842+
- fishing
843+
- cooking
844+
```
845+
846+
```yaml
847+
# toYamlPretty
848+
- name: bob
849+
age: 25
850+
hobbies:
851+
- hiking
852+
- fishing
853+
- cooking
854+
```
855+
829856
### fromYamlArray
830857

831858
The `fromYamlArray` function takes a YAML Array and returns a list that can be used in templates.

0 commit comments

Comments
 (0)