🛠Template Engine Built-in Functions
This document lists all available built-in functions with their descriptions, usage, and return types.
🔹 abs()
- Return Type:
num
- Description: Returns the absolute value of a number or numeric string.
- Usage:
{{ __value.abs() }}
🔹 base64Decode()
- Return Type:
String
- Description: Decodes a Base64 string. Optionally handles missing padding.
- Usage:
{{ __value.base64Decode() }}
🔹 base64Encode()
- Return Type:
String
- Description: Encodes a string to Base64. Optionally removes padding.
- Usage:
{{ __value.base64Encode() }}
🔹 ceil()
- Return Type:
int
- Description: Returns the smallest integer greater than or equal to a number.
- Usage:
{{ __value.ceil() }}
🔹 clean()
- Return Type:
String
- Description: Cleans a string (implementation depends on
cleanName
). - Usage:
{{ __value.clean() }}
🔹 contains()
- Return Type:
bool
- Description: Checks if a string or list contains a specified element.
- Usage:
{{ __value.contains() }}
🔹 containsKey()
- Return Type:
bool
- Description: Checks if a map contains a specific key.
- Usage:
{{ __value.containsKey() }}
🔹 containsValue()
- Return Type:
bool
- Description: Checks if a map contains a specific value.
- Usage:
{{ __value.containsValue() }}
🔹 endsWith()
- Return Type:
bool
- Description: Checks if a string ends with a specified substring.
- Usage:
{{ __value.endsWith() }}
🔹 equals()
- Return Type:
bool
- Description: Checks if two values are equal.
- Usage:
{{ __value.equals() }}
🔹 first()
- Return Type:
dynamic
- Description: Returns the first element of a non-empty list.
- Usage:
{{ __value.first() }}
🔹 floor()
- Return Type:
int
- Description: Returns the greatest integer less than or equal to a number.
- Usage:
{{ __value.floor() }}
🔹 get()
- Return Type:
dynamic
- Description: Retrieves a value from a map by key. Throws an error if the key is not found.
- Usage:
{{ __value.get() }}
🔹 getConfig()
- Return Type:
dynamic
- Description: Retrieves a configuration value.
- Usage:
{{ __value.getConfig() }}
🔹 getKeys()
- Return Type:
List<String>
- Description: [DEPRECATED] Use keys() instead. Returns a list of all keys in a map.
- Usage:
{{ __value.getKeys() }}
🔹 getOrNull()
- Return Type:
dynamic
- Description: Retrieves a value from a map by key, or returns null if the key is not found.
- Usage:
{{ __value.getOrNull() }}
🔹 getPathsV3()
- Return Type:
List<dynamic>
- Description: Parses and returns OpenAPI V3 paths.
- Usage:
{{ __value.getPathsV3() }}
🔹 getQueryV3()
- Return Type:
List<dynamic>
- Description: Parses and returns OpenAPI V3 queries.
- Usage:
{{ __value.getQueryV3() }}
🔹 getRequestBodyV3()
- Return Type:
Map<String, dynamic>
- Description: Extracts the schema from an OpenAPI V3 request body for a specific content type.
- Usage:
{{ __value.getRequestBodyV3() }}
🔹 getValues()
- Return Type:
List<dynamic>
- Description: [DEPRECATED] Use values() instead. Returns a list of all values in a map.
- Usage:
{{ __value.getValues() }}
🔹 getVar()
- Return Type:
dynamic
- Description: Retrieves a variable from the data collection.
- Usage:
{{ __value.getVar() }}
🔹 greaterThan()
- Return Type:
bool
- Description: Checks if the first numeric value is greater than the second.
- Usage:
{{ __value.greaterThan() }}
🔹 greaterThanOrEquals()
- Return Type:
bool
- Description: Checks if the first numeric value is greater than or equal to the second.
- Usage:
{{ __value.greaterThanOrEquals() }}
🔹 groupBy()
- Return Type:
Map<String, List<dynamic>>
- Description: Groups a map by a specified nested key.
- Usage:
{{ __value.groupBy() }}
🔹 ifNotTrueReturn()
- Return Type:
dynamic
- Description: If the value is falsy (null, zero, empty, false), returns the argument; otherwise, returns null.
- Usage:
{{ __value.ifNotTrueReturn() }}
🔹 ifTrueReturn()
- Return Type:
dynamic
- Description: If the value is truthy (non-null, non-zero, non-empty, true), returns the argument; otherwise, returns null.
- Usage:
{{ __value.ifTrueReturn() }}
🔹 isEmpty()
- Return Type:
bool
- Description: Checks if a string, list, or map is empty.
- Usage:
{{ __value.isEmpty() }}
🔹 isEven()
- Return Type:
bool
- Description: Checks if an integer or integer-like string is even.
- Usage:
{{ __value.isEven() }}
🔹 isNotEmpty()
- Return Type:
bool
- Description: Checks if a string, list, or map is not empty.
- Usage:
{{ __value.isNotEmpty() }}
🔹 isNotNull()
- Return Type:
bool
- Description: Checks if the input value is not null.
- Usage:
{{ __value.isNotNull() }}
🔹 isNull()
- Return Type:
bool
- Description: Checks if the input value is null.
- Usage:
{{ __value.isNull() }}
🔹 isOdd()
- Return Type:
bool
- Description: Checks if an integer or integer-like string is odd.
- Usage:
{{ __value.isOdd() }}
🔹 join()
- Return Type:
String
- Description: Joins elements of a list into a string using an optional delimiter.
- Usage:
{{ __value.join() }}
🔹 keys()
- Return Type:
List<dynamic>
- Description: Returns a list of all keys in a map.
- Usage:
{{ __value.keys() }}
🔹 last()
- Return Type:
dynamic
- Description: Returns the last element of a non-empty list.
- Usage:
{{ __value.last() }}
🔹 length()
- Return Type:
int
- Description: Returns the length of a string, list, or the number of keys in a map.
- Usage:
{{ __value.length() }}
🔹 lessThan()
- Return Type:
bool
- Description: Checks if the first numeric value is less than the second.
- Usage:
{{ __value.lessThan() }}
🔹 lessThanOrEquals()
- Return Type:
bool
- Description: Checks if the first numeric value is less than or equal to the second.
- Usage:
{{ __value.lessThanOrEquals() }}
🔹 notEquals()
- Return Type:
bool
- Description: Checks if two values are not equal.
- Usage:
{{ __value.notEquals() }}
🔹 openAPIType()
- Return Type:
String
- Description: Determines the OpenAPI type for a given schema and language.
- Usage:
{{ __value.openAPIType() }}
🔹 padLeft()
- Return Type:
String
- Description: Add the argument string to the left of the value.
- Usage:
{{ __value.padLeft() }}
🔹 padRight()
- Return Type:
String
- Description: Add the argument string to the right of the value.
- Usage:
{{ __value.padRight() }}
🔹 parseSchemas()
- Return Type:
Map
- Description: Parses all OpenAPI schemas.
- Usage:
{{ __value.parseSchemas() }}
🔹 range()
- Return Type:
List<int>
- Description: Generates a list of integers from 0 up to (but not including) the specified limit.
- Usage:
{{ __value.range() }}
🔹 raw()
- Return Type:
dynamic
- Description: Returns the argument value directly, useful for preventing further processing.
- Usage:
{{ __value.raw() }}
🔹 removeAll()
- Return Type:
String?
- Description: Removes all occurrences of a substring from a string.
- Usage:
{{ __value.removeAll() }}
🔹 reverse()
- Return Type:
List
- Description: Returns a new list with the elements of the original list in reverse order.
- Usage:
{{ __value.reverse() }}
🔹 round()
- Return Type:
int
- Description: Rounds a number to the nearest integer.
- Usage:
{{ __value.round() }}
🔹 setConfig()
- Return Type:
void
- Description: Sets a configuration value.
- Usage:
{{ __value.setConfig() }}
🔹 setVar()
- Return Type:
void
- Description: Sets a variable in the data collection.
- Usage:
{{ __value.setVar() }}
🔹 shuffle()
- Return Type:
List
- Description: Randomly shuffles the elements of a list.
- Usage:
{{ __value.shuffle() }}
🔹 sort()
- Return Type:
List
- Description: Sorts a list in ascending or descending order. Elements must be Comparable.
- Usage:
{{ __value.sort() }}
🔹 split()
- Return Type:
List<String>
- Description: Splits a string into a list of substrings by a delimiter.
- Usage:
{{ __value.split() }}
🔹 startsWith()
- Return Type:
bool
- Description: Checks if a string starts with a specified substring.
- Usage:
{{ __value.startsWith() }}
🔹 toCamelCase()
- Return Type:
String
- Description: Converts a string to camel case (e.g., 'hello world' to 'helloWorld').
- Usage:
{{ __value.toCamelCase() }}
🔹 toConstantCase()
- Return Type:
String
- Description: Converts a string to constant case (e.g., 'hello world' to 'HELLO_WORLD').
- Usage:
{{ __value.toConstantCase() }}
🔹 toDotCase()
- Return Type:
String
- Description: Converts a string to dot case (e.g., 'hello world' to 'hello.world').
- Usage:
{{ __value.toDotCase() }}
🔹 toDouble()
- Return Type:
double?
- Description: Converts a numeric value or a numeric string to a double. Returns null if the string cannot be parsed.
- Usage:
{{ __value.toDouble() }}
🔹 toHeaderCase()
- Return Type:
String
- Description: Converts a string to header case (e.g., 'hello world' to 'Hello-World').
- Usage:
{{ __value.toHeaderCase() }}
🔹 toInt()
- Return Type:
int?
- Description: Converts a numeric value or a numeric string to an integer. Returns null if the string cannot be parsed.
- Usage:
{{ __value.toInt() }}
🔹 toJson()
- Return Type:
String
- Description: Converts a Map to a JSON string. Accepts an optional integer 'arg' for indentation (pretty printing).
- Usage:
{{ __value.toJson() }}
🔹 toLowerCase()
- Return Type:
String
- Description: Converts a string to lowercase.
- Usage:
{{ __value.toLowerCase() }}
🔹 toParamCase()
- Return Type:
String
- Description: Converts a string to param case (e.g., 'hello world' to 'hello-world').
- Usage:
{{ __value.toParamCase() }}
🔹 toPascalCase()
- Return Type:
String
- Description: Converts a string to Pascal case (e.g., 'hello world' to 'HelloWorld').
- Usage:
{{ __value.toPascalCase() }}
🔹 toSentenceCase()
- Return Type:
String
- Description: Converts a string to sentence case (e.g., 'hello world' to 'Hello world').
- Usage:
{{ __value.toSentenceCase() }}
🔹 toSnakeCase()
- Return Type:
String
- Description: Converts a string to snake case (e.g., 'hello world' to 'hello_world').
- Usage:
{{ __value.toSnakeCase() }}
🔹 toTitleCase()
- Return Type:
String
- Description: Converts a string to title case (e.g., 'hello world' to 'Hello World').
- Usage:
{{ __value.toTitleCase() }}
🔹 toUpperCase()
- Return Type:
String
- Description: Converts a string to uppercase.
- Usage:
{{ __value.toUpperCase() }}
🔹 trim()
- Return Type:
String
- Description: Removes leading and trailing whitespace from a string.
- Usage:
{{ __value.trim() }}
🔹 unique()
- Return Type:
List
- Description: Returns a new list containing only the unique elements from the original list.
- Usage:
{{ __value.unique() }}
🔹 values()
- Return Type:
List<dynamic>
- Description: Returns a list of all values in a map.
- Usage:
{{ __value.values() }}
🔹 where()
- Return Type:
List
- Description: Filters a list, returning elements that are equal to the argument.
- Usage:
{{ __value.where() }}
🔹 whereNot()
- Return Type:
List
- Description: Filters a list, returning elements that are not equal to the argument.
- Usage:
{{ __value.whereNot() }}