Data Manipulation
String
func String(value interface{}) String
Returns a String class object that allows invoking standard string
operations as method.
append
func append(list interface{}, elements ...interface{}) IGenericList
Append new items to an existing list, creating a new list.
Aliases
array
func array(value interface{}) interface{}
Ensures that the supplied argument is an array (if it is already an
array/slice, there is no change, if not, the argument is replaced by
[]interface{} with a single value).
bool
func bool(str string) bool
Converts the `string` into boolean value (`string` must be `True`,
`true`, `TRUE`, `1` or `False`, `false`, `FALSE`, `0`)
char
func char(value interface{}) interface{}
Returns the character corresponging to the supplied integer value
contains
func contains(list interface{}, elements ...interface{}) bool
Tests whether a list contains all given elements (matches any types).
Aliases
containsStrict
func containsStrict(list interface{}, elements ...interface{}) bool
Tests whether a list contains all given elements (matches only the
same types).
Aliases
content
func content(keymap interface{}) interface{}
Returns the content of a single element map.
Used to retrieve content in a declaration like:
value "name" { a = 1 b = 3 }
dict
func dict(args ...interface{}) IDictionary
Returns a new dictionary from a list of pairs (key, value).
Aliases
func extract(source interface{}, indexes ...interface{}) interface{}
Extracts values from a slice or a map, indexes could be either
integers for slice or strings for maps.
find
func find(list interface{}, element interface{}) interface{}
Returns all index positions where the element is found in the list
(matches any types).
findStrict
func findStrict(list interface{}, element interface{}) interface{}
Returns all index positions where the element is found in the list
(matches only the same types).
get
func get(map interface{}, key interface{}, default ...interface{})
interface{}
Returns the value associated with the supplied map, key and map could
be inverted for convenience (i.e. when using piping mode).
hasKey
func hasKey(dictionary interface{}, key interface{}) interface{}
Returns true if the dictionary contains the specified key.
Examples
Razor: @hasKey(dict("key", "value"), "key")
Template: {{ hasKey (dict "key" "value") "key" }}
Result: true
Razor: @hasKey("key", dict("key", "value"))
Template: {{ hasKey "key" (dict "key" "value") }}
Result: true
Razor: @hasKey(dict("key", "value"), "otherkey")
Template: {{ hasKey (dict "key" "value") "otherkey" }}
Result: false
initial
func initial(list interface{}) interface{}
Returns but the last element.
intersect
func intersect(list interface{}, elements ...interface{}) IGenericList
Returns a list that is the intersection of the list and all arguments
(removing duplicates).
isNil
func isNil(arg1 interface{}) bool
Returns true if the supplied value is nil.
Aliases
isSet
func isSet(arg1 interface{}) bool
Returns true if the supplied value is not nil.
isZero
func isZero(arg1 interface{}) bool
Returns true if the supplied value is false, 0, nil or empty.
Aliases
key
func key(value interface{}) interface{}
Returns the key name of a single element map.
Used to retrieve name in a declaration like:
value "name" { a = 1 b = 3 }
keys
func keys(dictionary IDictionary) IGenericList
Returns a list of all of the keys in a dict (in alphabetical order).
lenc
func lenc(str string) int
Returns the number of actual character in a string.
Aliases
list
func list(args ...interface{}) IGenericList
Returns a generic list from the supplied arguments.
Aliases
merge
func merge(destination IDictionary, sources IDictionary, args
...IDictionary) IDictionary
Merges two or more dictionaries into one, giving precedence to the
dest dictionary.
omit
func omit(dict IDictionary, keys interface{}, args ...interface{})
IDictionary
Returns a new dict with all the keys that do not match the given keys.
pick
func pick(dict IDictionary, keys ...interface{}) IDictionary
Selects just the given keys out of a dictionary, creating a new dict.
pickv
func pickv(dict IDictionary, message string, keys interface{}, args
...interface{}) interface{}
Same as pick, but returns an error message if there are intruders in
supplied dictionary.
pluck
func pluck(key interface{}, dictionaries ...IDictionary) IGenericList
Extracts a list of values matching the supplied key from a list of
dictionary.
prepend
func prepend(list interface{}, elements ...interface{}) IGenericList
Push elements onto the front of a list, creating a new list.
removeEmpty
func removeEmpty(list interface{}) IGenericList
Returns a list with all empty elements removed.
removeNil
func removeNil(list interface{}) IGenericList
Returns a list with all nil elements removed.
rest
func rest(list interface{}) interface{}
Gets the tail of the list (everything but the first item)
reverse
func reverse(list interface{}) IGenericList
Produces a new list with the reversed elements of the given list.
safeIndex
func safeIndex(value interface{}, index int, default interface{})
interface{}
Returns the element at index position or default if index is outside
bounds.
set
func set(dict interface{}, key interface{}, value interface{}) string
Adds the value to the supplied map using key as identifier.
slice
func slice(value interface{}, args ...interface{}) interface{}
Returns a slice of the supplied object (equivalent to
object[from:to]).
string
func string(value interface{}) string
Converts the supplied value into its string representation.
undef
func undef(default interface{}, values ...interface{}) interface{}
Returns the default value if value is not set, alias `undef` (differs
from Sprig `default` function as empty value such as 0, false, "" are
not considered as unset).
Aliases
union
func union(list interface{}, elements ...interface{}) IGenericList
Returns a list that is the union of the list and all arguments
(removing duplicates).
unique
func unique(list interface{}) IGenericList
Generates a list with all of the duplicates removed.
Aliases
unset
func unset(dictionary interface{}, key interface{}) string
Removes an element from a dictionary.
Aliases
Examples
Razor: @{myDict} := dict("key", "value", "key2", "value2", "key3", "value3")
@-unset($myDict, "key")
@-unset("key2", $myDict)
@-toJson($myDict)
Template: {{- $myDict := dict "key" "value" "key2" "value2" "key3" "value3" }}
{{- unset $myDict "key" }}
{{- unset "key2" $myDict }}
{{- toJson $myDict }}
Result: {"key3":"value3"}
values
func values(arg1 IDictionary) IGenericList
Returns the list of values contained in a map.
without
func without(list interface{}, elements ...interface{}) IGenericList
Filters items out of a list.