From b1730c1956aed244d9d05255c95f427fdfcf4d1e Mon Sep 17 00:00:00 2001 From: Dave Henderson Date: Sun, 4 Jun 2017 16:04:36 -0400 Subject: Adding TOML support Signed-off-by: Dave Henderson --- docs/content/functions.md | 68 ++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 67 insertions(+), 1 deletion(-) (limited to 'docs/content') diff --git a/docs/content/functions.md b/docs/content/functions.md index c8962146..2cf6a6c7 100644 --- a/docs/content/functions.md +++ b/docs/content/functions.md @@ -372,6 +372,44 @@ $ gomplate < input.tmpl Hello world ``` +## `toml` + +Converts a [TOML](https://github.com/toml-lang/toml) document into an object. +This can be used to access properties of TOML documents. + +Compatible with [TOML v0.4.0](https://github.com/toml-lang/toml/blob/master/versions/en/toml-v0.4.0.md). + +### Usage + +```go +toml input +``` + +Can also be used in a pipeline: +```go +input | toml +``` + +### Arguments + +| name | description | +|--------|-------| +| `input` | the TOML document to parse | + +#### Example + +_`input.tmpl`:_ +``` +{{ $t := `[data] +hello = "world"` -}} +Hello {{ (toml $t).hello }} +``` + +```console +$ gomplate -f input.tmpl +Hello world +``` + ## `csv` Converts a CSV-format string into a 2-dimensional string array. @@ -547,6 +585,34 @@ $ gomplate < input.tmpl hello: world ``` +## `toTOML` + +Converts an object to a [TOML](https://github.com/toml-lang/toml) document. + +### Usage + +```go +toTOML obj +``` + +Can also be used in a pipeline: +```go +obj | toTOML +``` + +### Arguments + +| name | description | +|--------|-------| +| `obj` | the object to marshal as a TOML document | + +#### Example + +```console +$ gomplate -i '{{ `{"foo":"bar"}` | json | toTOML }}' +foo = "bar" +``` + ## `toCSV` Converts an object to a CSV document. The input object must be a 2-dimensional @@ -598,7 +664,7 @@ Parses a given datasource (provided by the [`--datasource/-d`](#--datasource-d) Currently, `file://`, `http://`, `https://`, and `vault://` URLs are supported. -Currently-supported formats are JSON, YAML, and CSV. +Currently-supported formats are JSON, YAML, TOML, and CSV. #### Examples -- cgit v1.2.3