From b669b8a8b58fd7d8fe175b7318cbb1444d839f99 Mon Sep 17 00:00:00 2001 From: Dave Henderson Date: Tue, 24 Oct 2023 10:31:59 -0400 Subject: Support for CUE (#1781) Signed-off-by: Dave Henderson --- docs-src/content/functions/data.yml | 46 +++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) (limited to 'docs-src/content') diff --git a/docs-src/content/functions/data.yml b/docs-src/content/functions/data.yml index 9392790d..6753cafe 100644 --- a/docs-src/content/functions/data.yml +++ b/docs-src/content/functions/data.yml @@ -383,6 +383,27 @@ funcs: Go COBOL ``` + - name: data.CUE + alias: cue + description: | + 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). + pipeline: true + arguments: + - name: input + required: true + description: the CUE document to parse + examples: + - | + $ gomplate -i '{{ $t := `data: { + hello: "world" + }` -}} + Hello {{ (cue $t).data.hello }}' + Hello world - name: data.ToJSON alias: toJSON released: v2.0.0 @@ -511,3 +532,28 @@ funcs: 1,2 3,4 ``` + - name: data.ToCUE + alias: toCUE + description: | + 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. + pipeline: true + arguments: + - name: input + required: true + description: the object to marshal as a CUE document + examples: + - | + $ gomplate -i '{{ `{"foo":"bar"}` | data.JSON | data.ToCUE }}' + { + foo: "bar" + } + - | + $ gomplate -i '{{ toCUE "hello world" }}' + "hello world" + - | + $ gomplate -i '{{ coll.Slice 1 "two" true | data.ToCUE }}' + [1, "two", true] -- cgit v1.2.3