Replies: 4 comments
-
|
I just discovered the "ref" operator. So, the following may work without coping the entire document to a variable. I don't have access to my development environment at the moment, but I will try this as soon as I do. |
Beta Was this translation helpful? Give feedback.
-
|
Ok, ". ref $root" appears to work as well as ". as $root", and hopefully is a more efficient way to evaluate expressions relative to the whole document. This "!eval" tag implementation might make a good example use of the eval operator. |
Beta Was this translation helpful? Give feedback.
-
|
The previous "!eval" tag implemenation requires some ugly quoting if the expression is a string to be interpolated. The following complementary "!streval" tag implementation avoids this. |
Beta Was this translation helpful? Give feedback.
-
|
Possible yq enhancement. Add a "evalsubst" operator similar to "envsubst", but to perform yq expression substitutions instead of environment variables. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I would like to implement a YAML "!eval" tag which will evaluate a yq expression and assign the result to the key value.
The relative assignment operator changes the context so expressions relative to the entire document do not work. I was able to work around this by first saving the document to a variable, and then use that in the relative assignment RHS.
This seems like this could be inefficient if the document is large. Is there a better way to do this?
Beta Was this translation helpful? Give feedback.
All reactions