Documentation ¶
Index ¶
- func CelCompileAndEval(ctx context.Context, scope *Scope, expr model.String, outPtr any) error
- func SortStrings(in []string) []string
- func ToHyphenCase(v string) string
- func ToLowerHyphenCase(v string) string
- func ToLowerSnakeCase(v string) string
- func ToSnakeCase(v string) string
- func ToUpperHyphenCase(v string) string
- func ToUpperSnakeCase(v string) string
- type Scope
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CelCompileAndEval ¶
celCompileAndEval parses, compiles, and executes the given CEL expr with the given variables in scope.
The output of CEL execution is written into the location pointed to by outPtr. It must be a pointer. If the output of the CEL expression can't be converted to the given type, then an error will be returned. For example, if the CEL expression is "hello" and outPtr points to an int, an error will returned because CEL cannot treat "hello" as an integer.
func SortStrings ¶
sortStrings sorts the given list of strings. Go's built-in sorting behavior modifies the string in place. It would be very weird if rendering a template changed the order of an input further down the stack.
func ToHyphenCase ¶
toHyphenCase converts a string to hyphen-case by removing all characters (except alphanumeric, hyphens, underscores and spaces) and replacing any hyphens or spaces with underscores.
func ToLowerHyphenCase ¶
toLowerHyphenCase converts a string to hyphen-case by removing all characters (except alphanumeric, hyphens, underscores and spaces) and replacing any underscores or spaces with hyphens. The result is then returned as a lower case string.
func ToLowerSnakeCase ¶
toLowerSnakeCase converts a string to snake_case by removing all characters (except alphanumeric, hyphens, underscores and spaces) and replacing any hyphens or spaces with underscores. The result is then returned as a lower case string.
func ToSnakeCase ¶
toSnakeCase converts a string to snake_case by removing all characters (except alphanumeric, hyphens, underscores and spaces) and replacing any hyphens or spaces with underscores.
func ToUpperHyphenCase ¶
toUpperSnakeCase converts a string to hyphen-case by removing all characters (except alphanumeric, hyphens, underscores and spaces) and replacing any underscores or spaces with hyphens. The result is then returned as a upper case string.
func ToUpperSnakeCase ¶
toUpperSnakeCase converts a string to snake_case by removing all characters (except alphanumeric, hyphens, underscores and spaces) and replacing any hyphens or spaces with underscores. The result is then returned as a upper case string.
Types ¶
type Scope ¶
type Scope struct {
// contains filtered or unexported fields
}
scope binds variable names to values. It has a stack-like structure that allows inner scopes to inherit values from outer scopes. Variable names are looked up in order of innermost-to-outermost.
For example, a for_each action defines a key value that is assigned to each of a list of values. The new variable introduced in this way "shadows" any variable that may previously exist of the same name. When the for_each loop is finished, then the outer scope's variable becomes available again.
func (*Scope) All ¶
All returns all variable bindings that are in scope. Inner/top-of-stack bindings take priority over outer bindings of the same name.
The returned map is a copy that is owned by the caller; it can be changed safely.
The return value is never nil.