Allowed Functions

Inline Transformation Functions allow you to apply operations directly inside expressions wrapped with {{ }}. Functions can be chained, and execution happens left to right. The output of one function becomes the input for the next.

Example: {{ 3.response.name.toUpper().startsWith("A").fallback(false) }}

Boolean Functions

toBoolean()

  • Converts the current value to a boolean using the Convert utility.

  • Allowed Parameters: None

  • Structure: toBoolean()

  • Examples:

    • {{ "true".toBoolean() }}

    • {{ 1.toBoolean() }}

toggle()

  • Toggle the current boolean value (True becomes False, False becomes True).

  • Allowed Parameters: None

  • Structure: toggle()

  • Examples:

    • {{ is_active.toggle() }}

    • {{ true.toggle() }}

and()

  • Perform a logical AND between the current boolean value and another value.

  • Allowed Parameters: rhs (Any)

  • Structure: and(rhs)

  • Examples:

    • {{ is_valid.and(is_authenticated) }}

or()

  • Perform a logical OR between the current boolean value and another value.

  • Allowed Parameters: rhs (Any)

  • Structure: or(rhs)

  • Examples:

    • {{ is_admin.or(is_editor) }}

String Functions

toUpper()

  • Converts the current string value to uppercase.

  • Allowed Parameters: None

  • Structure: toUpper()

  • Examples:

    • {{ user.name.toUpper() }}

toLower()

  • Converts the current string value to lowercase.

  • Allowed Parameters: None

  • Structure: toLower()

  • Examples:

    • {{ "HELLO".toLower() }}

trim()

  • Remove leading and trailing whitespace from the current string value.

  • Allowed Parameters: None

  • Structure: trim()

  • Examples:

    • {{ " hello ".trim() }}

toString()

  • Converts the current value to a string.

  • Allowed Parameters: None

  • Structure: toString()

  • Examples:

    • {{ price.toString() }}

contains()

  • Check if the current string value contains the given substring.

  • Allowed Parameters: substring (string)

  • Structure: contains(substring)

  • Examples:

    • {{ email.contains("@") }}

startsWith()

  • Check if the current string value starts with the given prefix.

  • Allowed Parameters: prefix (string)

  • Structure: startsWith(prefix)

  • Examples:

    • {{ phone.startsWith("+1") }}

endsWith()

  • Check if the current string value ends with the given suffix.

  • Allowed Parameters: suffix (string)

  • Structure: endsWith(suffix)

  • Examples:

    • {{ filename.endsWith(".pdf") }}

replace()

  • Replace all occurrences of a substring with a new substring.

  • Allowed Parameters: old (string), new (string)

  • Structure: replace(old,new)

  • Examples:

    • {{ text.replace("bad", "good") }}

slugify()

  • Convert the current string value into a slug (lowercase, hyphen-separated).

  • Allowed Parameters: None

  • Structure: slugify()

  • Examples:

    • {{ title.slugify() }}

split()

  • Split the current string value into a list using the given separator.

  • Allowed Parameters: sep (Any)

  • Structure: split(sep)

  • Examples:

    • {{ tags.split(",") }}

substring()

  • Extract a substring using start and optional end indices.

  • Allowed Parameters: start (int), end (int, optional)

  • Structure: substring(start,end)

  • Examples:

    • {{ "Elephant".substring(0, 3) }}

toTitleCase()

  • Convert the current string value to title case (capitalize each word).

  • Allowed Parameters: None

  • Structure: toTitleCase()

  • Examples:

    • {{ "john doe".toTitleCase() }}

toNumber()

  • Convert the current string value to a number.

  • Allowed Parameters: None

  • Structure: toNumber()

  • Examples:

    • {{ "42.5".toNumber() }}

padStart()

  • Pad the current string on the left until it reaches the given length.

  • Allowed Parameters: length (int), char (string, optional)

  • Structure: padStart(length,char)

  • Examples:

    • {{ "5".padStart(2, "0") }}

padEnd()

  • Pad the current string on the right until it reaches the given length.

  • Allowed Parameters: length (int), char (string, optional)

  • Structure: padEnd(length,char)

  • Examples:

    • {{ "5".padEnd(3, "0") }}

parseJSON()

  • Parse the current string value as JSON safely.

  • Allowed Parameters: None

  • Structure: parseJSON()

  • Examples:

    • {{ json_string.parseJSON() }}

Numeric Functions

add()

  • Add a given number to the current value.

  • Allowed Parameters: number (Any)

  • Structure: add(number)

  • Examples:

    • {{ 10.add(5) }}

subtract()

  • Subtract a given number from the current value.

  • Allowed Parameters: number (Any)

  • Structure: subtract(number)

  • Examples:

    • {{ 20.subtract(5) }}

increment()

  • Increase the current numeric value by 1.

  • Allowed Parameters: None

  • Structure: increment()

  • Examples:

    • {{ count.increment() }}

decrement()

  • Decrease the current numeric value by 1.

  • Allowed Parameters: None

  • Structure: decrement()

  • Examples:

    • {{ count.decrement() }}

round()

  • Round the current float value to the specified decimal places.

  • Allowed Parameters: decimals (int, optional)

  • Structure: round(decimals)

  • Examples:

    • {{ 3.14159.round(2) }}

toInteger()

  • Convert the current float value to an integer.

  • Allowed Parameters: args (Any)

  • Structure: toInteger(args)

  • Examples:

    • {{ 9.99.toInteger() }}


List Functions

length()

  • Get the number of items in the current list.

  • Allowed Parameters: None

  • Structure: length()

  • Examples:

    • {{ items.length() }}

push()

  • Append an item to the end of the current list.

  • Allowed Parameters: item (Any)

  • Structure: push(item)

  • Examples:

    • {{ cart.push("apple") }}

prepend()

  • Insert an item at the beginning of the current list.

  • Allowed Parameters: item (Any)

  • Structure: prepend(item)

  • Examples:

    • {{ history.prepend("new_event") }}

pop()

  • Remove the last item from the current list.

  • Allowed Parameters: None

  • Structure: pop()

  • Examples:

    • {{ stack.pop() }}

removeAt()

  • Remove the item at the specified index.

  • Allowed Parameters: index (int)

  • Structure: removeAt(index)

  • Examples:

    • {{ list.removeAt(0) }}

extend()

  • Extend the list by appending all items from another list.

  • Allowed Parameters: items (Any)

  • Structure: extend(items)

  • Examples:

    • {{ list_a.extend(list_b) }}

unique()

  • Remove duplicate items from the current list.

  • Allowed Parameters: None

  • Structure: unique()

  • Examples:

    • {{ categories.unique() }}

join()

  • Join all items in the list into a string.

  • Allowed Parameters: sep (Any)

  • Structure: join(sep)

  • Examples:

    • {{ words.join(" ") }}

pluck()

  • Extract values for a given key from each dictionary in the list.

  • Allowed Parameters: key (Any)

  • Structure: pluck(key)

  • Examples:

    • {{ users.pluck("id") }}

filter()

  • Filter items based on a condition (use 'element' as context).

  • Allowed Parameters: condition (string)

  • Structure: filter(condition)

  • Examples:

    • {{ numbers.filter("element > 10") }}


JSON Functions (Objects and Arrays)

setKey()

  • Set a key in the JSON object to the given value.

  • Allowed Parameters: key (Any), value (Any)

  • Structure: setKey(key,value)

  • Examples:

    • {{ user.setKey("status", "active") }}

removeKey()

  • Remove a key from the JSON object.

  • Allowed Parameters: key (Any)

  • Structure: removeKey(key)

  • Examples:

    • {{ user.removeKey("password") }}

merge()

  • Merge another dictionary into the current object.

  • Allowed Parameters: obj (Any)

  • Structure: merge(obj)

  • Examples:

    • {{ settings.merge(default_settings) }}

pick()

  • Create a new object containing only the specified keys.

  • Allowed Parameters: keys (Any)

  • Structure: pick(keys)

  • Examples:

    • {{ profile.pick(["name", "email"]) }}


DateTime Functions

fromTimestamp()

  • Convert a Unix timestamp into a UTC datetime value.

  • Allowed Parameters: ts (int)

  • Structure: fromTimestamp(ts)

  • Examples:

    • {{ 1704067200.fromTimestamp() }}

toTimestamp()

  • Convert the current datetime value into a Unix timestamp.

  • Allowed Parameters: None

  • Structure: toTimestamp()

  • Examples:

    • {{ now.toTimestamp() }}

format()

  • Format the datetime into a string with optional timezone.

  • Allowed Parameters: format (string, optional), tz (string, optional)

  • Structure: format(format,tz)

  • Examples:

    • {{ event.date.format("%Y-%m-%d", "UTC") }}

addDays()

  • Add a given number of days to the current datetime.

  • Allowed Parameters: number (int)

  • Structure: addDays(number)

  • Examples:

    • {{ today.addDays(7) }}

subtractDays()

  • Subtract a given number of days from the current datetime.

  • Allowed Parameters: number (int)

  • Structure: subtractDays(number)

  • Examples:

    • {{ today.subtractDays(1) }}

addHours()

  • Add a given number of hours to the current datetime.

  • Allowed Parameters: number (int)

  • Structure: addHours(number)

  • Examples:

    • {{ now.addHours(2) }}

diffDays()

  • Calculate the difference in days between two datetimes.

  • Allowed Parameters: other (Any)

  • Structure: diffDays(other)

  • Examples:

    • {{ deadline.diffDays(now) }}

isAfter()

  • Check if the current datetime is after another datetime.

  • Allowed Parameters: other (Any)

  • Structure: isAfter(other)

  • Examples:

    • {{ delivery_date.isAfter(order_date) }}

isBefore()

  • Check if the current datetime is before another datetime.

  • Allowed Parameters: other (Any)

  • Structure: isBefore(other)

  • Examples:

    • {{ start_date.isBefore(end_date) }}

startOfDay()

  • Set the datetime to 00:00:00.

  • Allowed Parameters: None

  • Structure: startOfDay()

  • Examples:

    • {{ now.startOfDay() }}

endOfDay()

  • Set the datetime to 23:59:59.999999.

  • Allowed Parameters: None

  • Structure: endOfDay()

  • Examples:

    • {{ now.endOfDay() }}

getDate()

  • Extract the date portion as an ISO string (YYYY-MM-DD).

  • Allowed Parameters: None

  • Structure: getDate()

  • Examples:

    • {{ event.getDate() }}

getTime()

  • Extract the time portion as an ISO string (HH:MM:SS).

  • Allowed Parameters: None

  • Structure: getTime()

  • Examples:

    • {{ now.getTime() }}

toISO()

  • Convert the datetime into an ISO 8601 string.

  • Allowed Parameters: None

  • Structure: toISO()

  • Examples:

    • {{ updated_at.toISO() }}

toRFC2822()

  • Convert the datetime into an RFC 2822 string.

  • Allowed Parameters: None

  • Structure: toRFC2822()

  • Examples:

    • {{ created_at.toRFC2822() }}

Utility Functions

fallback()

  • Returns the specified fallback value if a runtime error occurs during execution.

  • Allowed Parameters: Any (accepts fallback value in syntax)

  • Structure: fallback("Fallback Value")

  • Examples:

    • {{ user.address.city.fallback("N/A") }}

Last updated

Was this helpful?