From edaf202f95bd52c35ba54c54452e8940002cf897 Mon Sep 17 00:00:00 2001 From: Dave Henderson Date: Sun, 12 May 2024 13:54:28 -0400 Subject: ci(docs): Require up-to-date function docs (#2071) * ci(docs): Require up-to-date function docs Signed-off-by: Dave Henderson * docs(fix): update regenerated docs Signed-off-by: Dave Henderson --------- Signed-off-by: Dave Henderson --- docs/content/functions/data.md | 80 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 80 insertions(+) (limited to 'docs') diff --git a/docs/content/functions/data.md b/docs/content/functions/data.md index 9fd278f4..1c382157 100644 --- a/docs/content/functions/data.md +++ b/docs/content/functions/data.md @@ -536,6 +536,43 @@ Go COBOL ``` +## `data.CUE`_(unreleased)_ +**Unreleased:** _This function is in development, and not yet available in released builds of gomplate._ + +**Alias:** `cue` + +Converts a [CUE](https://cuelang.org/) document into an object. Any type +of CUE document is supported. This can be used to access properties of CUE +documents. + +Note that the `import` statement is not yet supported, and will result in +an error (except for importing builtin packages). + +### Usage + +``` +data.CUE input +``` +``` +input | data.CUE +``` + +### Arguments + +| name | description | +|------|-------------| +| `input` | _(required)_ the CUE document to parse | + +### Examples + +```console +$ gomplate -i '{{ $t := `data: { + hello: "world" + }` -}} + Hello {{ (cue $t).data.hello }}' +Hello world +``` + ## `data.ToJSON` **Alias:** `toJSON` @@ -726,3 +763,46 @@ first,second 1,2 3,4 ``` + +## `data.ToCUE`_(unreleased)_ +**Unreleased:** _This function is in development, and not yet available in released builds of gomplate._ + +**Alias:** `toCUE` + +Converts an object to a [CUE](https://cuelang.org/) document in canonical +format. The input object can be of any type. + +This is roughly equivalent to using the `cue export --out=cue ` +command to convert from other formats to CUE. + +### Usage + +``` +data.ToCUE input +``` +``` +input | data.ToCUE +``` + +### Arguments + +| name | description | +|------|-------------| +| `input` | _(required)_ the object to marshal as a CUE document | + +### Examples + +```console +$ gomplate -i '{{ `{"foo":"bar"}` | data.JSON | data.ToCUE }}' +{ + foo: "bar" +} +``` +```console +$ gomplate -i '{{ toCUE "hello world" }}' +"hello world" +``` +```console +$ gomplate -i '{{ coll.Slice 1 "two" true | data.ToCUE }}' +[1, "two", true] +``` -- cgit v1.2.3