Sprig Default

Sprig Default #

coalesce #

func coalesce(args ...interface{}) interface{}
Takes a list of values and returns the first non-empty one.

compact #

func compact(list interface{}) []interface{}
Removes entries with empty values.

default #

func default(default interface{}, value ...interface{}) interface{}
Set a simple default value.

empty #

func empty(value interface{}) bool
Returns true if the given value is considered empty.

fromJsonSprig #

func fromJsonSprig(arg1 string) interface{}
Decodes a JSON document into a structure. If the input cannot be
decoded as JSON the function will return an empty string. mustFromJson
will return an error in case the JSON is invalid.

Aliases #

  • fromJson

ternarySprig #

func ternarySprig(true interface{}, false interface{}, condition bool)
interface{}
If the test value is true, the first value will be returned,
otherwise, the second is returned.

Aliases #

  • ternary

toJsonSprig #

func toJsonSprig(object interface{}) string
Encodes an item into a JSON string.

Aliases #

  • toJson

toPrettyJsonSprig #

func toPrettyJsonSprig(object interface{}) string
Encodes an item into a pretty (indented) JSON string.

Aliases #

  • toPrettyJson

toRawJson #

func toRawJson(object interface{}) string
Encodes an item into JSON string with HTML characters unescaped.