Expr
Categories:
Expr is an expression language for returning values. It provides methods for comparing, iterating, and evaluating data.
Format
Expr looks very similar to Go:
status == "Done"You can learn more about the formatting for Expr on the Expr website: https://expr-lang.org/
Key Concepts
Standard Library
Expr ships with a number of standard functions. You can read about them here: https://expr-lang.org/docs/language-definition.
Custom Functions
Expr can be extended with custom functions. These functions are non-standard and are supported only within the our Jsonnet implementation.
countMatches(str string, regexp string) int
This function returns the number of matches of a Go regexp against a string.
countMatches("Hello World!", `o`) // 2json(obj ...any)
This function logs any object as JSON values to stderr. Useful for debugging.
json(myobj)methods(obj any)
This function logs any methods for an object to stderr. Useful for debugging.
methods(myobj)sprintf(format string, a ...any) string
This function performs string formatting, is a wrapper around Go’s fmt.Sprintf.
sprintf("Hello %s", "world") // "Hello world"