Skip to main content
This article provides a comprehensive reference for all Handlebars helpers available in WireMock Cloud’s response templating system.

Date and Time Helpers

now

Renders the current date/time with optional formatting and offset. Parameters:
  • format: Date format string (optional, defaults to ISO8601)
  • offset: Time offset (e.g., ‘3 days’, ‘-24 seconds’)
  • timezone: Timezone (optional, defaults to UTC)
Usage:
{{now}}
{{now offset='3 days'}}
{{now offset='-24 seconds'}}
{{now offset='10 years' format='yyyy-MM-dd'}}
{{now timezone='Australia/Sydney' format='yyyy-MM-dd HH:mm:ssZ'}}
{{now format='epoch'}}
{{now format='unix'}}
See Dates and Times for more details.

date

Manipulates existing date values with offset, timezone, and format changes. Parameters:
  • First parameter: Date value
  • format: Date format string (optional)
  • offset: Time offset (optional)
  • timezone: Timezone (optional)
Usage:
{{date myDate offset='-1 days' timezone='America/New_York' format='yyyy-MM-dd'}}
See Dates and Times for more details.

parseDate

Parses date strings into date objects. Parameters:
  • First parameter: Date string
  • format: Parser format string (optional)
Usage:
{{parseDate request.headers.MyDate}}
{{parseDate '10/11/2021' format="dd/MM/yyyy"}}
{{parseDate '1577964091000' format="epoch"}}
{{parseDate '1577964091' format="unix"}}
See Dates and Times for more details.

dateFormat

Formats date values to strings using predefined or custom formats. Parameters:
  • First parameter: Date value
  • Second parameter: Format name (full, long, medium, short) or custom format string
  • format: Alternative way to specify format string
Usage:
{{dateFormat (parseDate '2020-01-01T11:11:11Z') 'full'}}
{{dateFormat (parseDate '2020-01-01T11:11:11Z') format='yyyy-MM-dd'}}
See Dates and Times for more details.

truncateDate

Truncates date/times to specific points. Parameters:
  • First parameter: Date value
  • Second parameter: Truncation point
Truncation points:
  • first minute of hour
  • first hour of day
  • first day of month
  • first day of next month
  • last day of month
  • first day of year
  • first day of next year
  • last day of year
Usage:
{{truncateDate (parseDate '2021-06-14T00:00:00Z') 'last day of month'}}
See Dates and Times for more details.

String Helpers

regexExtract

Extracts values from strings using regular expressions. Parameters:
  • First parameter: Input string
  • Second parameter: Regular expression pattern
  • Third parameter (optional): Variable name to assign captured groups
Usage:
{{regexExtract request.body '[A-Z]+'}}
{{regexExtract request.body '([a-z]+)-([A-Z]+)-([0-9]+)' 'parts'}}
{{parts.0}},{{parts.1}},{{parts.2}}
See String Helpers for more details.

trim

Removes whitespace from the start and end of strings. Usage:
{{trim request.headers.X-Padded-Header}}

{{#trim}}
    Some stuff with whitespace
{{/trim}}
See String Helpers for more details.

abbreviate

Truncates strings that exceed a specified length, adding ellipsis. Parameters:
  • First parameter: Input string
  • Second parameter: Maximum length
Usage:
{{abbreviate 'Mocking APIs helps you develop faster' 21}}
Output: Mocking APIs helps... See String Helpers for more details.

capitalize

Capitalizes the first letter of each word. Parameters:
  • First parameter: Input string
Usage:
{{capitalize 'mock my stuff'}}
Output: Mock My Stuff See String Helpers for more details.

capitalizeFirst

Capitalizes only the first character of the string. Parameters:
  • First parameter: Input string
Usage:
{{capitalizeFirst 'mock my stuff'}}
Output: Mock my stuff See String Helpers for more details.

center

Centers text in a field of given width. Parameters:
  • First parameter: Input string
  • size: Field width (required)
  • pad: Padding character (optional, defaults to space)
Usage:
{{center 'hello' size=21}}
{{center 'hello' size=21 pad='#'}}
See String Helpers for more details.

cut

Removes all instances of a specified substring. Parameters:
  • First parameter: Input string
  • Second parameter: Substring to remove
Usage:
{{cut 'mocking, stubbing, faults' ','}}
Output: mocking stubbing faults See String Helpers for more details.

defaultIfEmpty

Returns the input value if not empty, otherwise returns a default. Parameters:
  • First parameter: Input value
  • Second parameter: Default value
Usage:
{{defaultIfEmpty 'my value' 'default'}}
{{defaultIfEmpty '' 'default'}}
See String Helpers for more details.

join

Joins multiple values or collections into a single string. Parameters:
  • Multiple values to join
  • Last parameter: Separator string
  • prefix: Optional prefix
  • suffix: Optional suffix
Usage:
{{join 'Mark' 'Rob' 'Dan' ', '}}
{{join 'Mark' 'Rob' 'Dan' ', ' prefix='[' suffix=']'}}
See String Helpers for more details.

ljust

Left-aligns text in a field of given width. Parameters:
  • First parameter: Input string
  • size: Field width (required)
  • pad: Padding character (optional)
Usage:
{{ljust 'things' size=20}}
{{ljust 'things' size=20 pad='#'}}
See String Helpers for more details.

rjust

Right-aligns text in a field of given width. Parameters:
  • First parameter: Input string
  • size: Field width (required)
  • pad: Padding character (optional)
Usage:
{{rjust 'things' size=20}}
{{rjust 'things' size=20 pad='#'}}
See String Helpers for more details.

lower

Converts string to lowercase. Parameters:
  • First parameter: Input string
Usage:
{{lower 'WireMock Cloud'}}
Output: wiremock cloud See String Helpers for more details.

upper

Converts string to uppercase. Parameters:
  • First parameter: Input string
Usage:
{{upper 'WireMock Cloud'}}
Output: WIREMOCK CLOUD See String Helpers for more details.

replace

Replaces all occurrences of a substring with another. Parameters:
  • First parameter: Input string
  • Second parameter: Substring to find
  • Third parameter: Replacement string
Usage:
{{replace 'the wrong way' 'wrong' 'right'}}
Output: the right way See String Helpers for more details.

slugify

Converts text to URL-friendly slug format. Parameters:
  • First parameter: Input string
Usage:
{{slugify 'Mock my APIs'}}
Output: mock-my-apis See String Helpers for more details.

stripTags

Removes all HTML/XML tags from string. Parameters:
  • First parameter: Input string
Usage:
{{stripTags '<greeting>hi</greeting>'}}
Output: hi See String Helpers for more details.

substring

Extracts a portion of a string between indices. Parameters:
  • First parameter: Input string
  • Second parameter: Start index
  • Third parameter (optional): End index
Usage:
{{substring 'one two' 4}}
{{substring 'one two' 0 3}}
See String Helpers for more details.

wordWrap

Wraps text at specified line length. Parameters:
  • First parameter: Input string
  • Second parameter: Line length
Usage:
{{wordWrap 'one two three' 4}}
See String Helpers for more details.

yesno

Maps boolean/null values to customizable yes/no/maybe strings. Parameters:
  • First parameter: Boolean or null value
  • yes: Custom yes string (optional)
  • no: Custom no string (optional)
  • maybe: Custom maybe/null string (optional)
Usage:
{{yesno true}}
{{yesno false}}
{{yesno null}}
{{yesno true yes='aye'}}
{{yesno false no='nay'}}
{{yesno null maybe='meh'}}
See String Helpers for more details.

Encoding Helpers

base64

Encodes or decodes Base64 strings. Parameters:
  • First parameter: Input string
  • decode: Set to true for decoding (optional)
  • padding: Set to false to disable padding (optional)
Usage:
{{{base64 request.headers.X-Plain-Header}}}
{{{base64 request.headers.X-Plain-Header padding=false}}}
{{{base64 request.headers.X-Encoded-Header decode=true}}}

{{{#base64}}}
Content to encode
{{{/base64}}}

{{{#base64 decode=true}}}
Q29udGVudCB0byBkZWNvZGUK
{{{/base64}}}
See String Encodings for more details.

urlEncode

Encodes or decodes URL strings according to HTTP URL encoding standard. Parameters:
  • First parameter: Input string
  • decode: Set to true for decoding (optional)
Usage:
{{{urlEncode request.headers.X-Plain-Header}}}
{{{urlEncode request.headers.X-Encoded-Header decode=true}}}

{{{#urlEncode}}}
Content to encode
{{{/urlEncode}}}

{{{#urlEncode decode=true}}}
Content%20to%20decode
{{{/urlEncode}}}
See String Encodings for more details.

formData

Parses HTTP form data into an object. Parameters:
  • First parameter: Form data string
  • Second parameter: Variable name to assign
  • urlDecode: Set to true to URL decode values (optional)
Usage:
{{formData request.body 'form' urlDecode=true}}{{{form.formField3}}}
{{formData request.body 'form' urlDecode=true}}{{{form.multiValueField.1}}}
{{formData request.body 'form' urlDecode=true}}{{{form.multiValueField.first}}}
See String Encodings for more details.

Number Helpers

math

Performs arithmetic operations. Parameters:
  • First parameter: Left operand
  • Second parameter: Operator (+, -, *, /, %)
  • Third parameter: Right operand
Operators:
  • +: Addition
  • -: Subtraction
  • *: Multiplication
  • /: Division
  • %: Modulo (remainder)
Usage:
{{math 1 '+' 2}}
{{math 4 '-' 2}}
{{math 2 '*' 3}}
{{math 8 '/' 2}}
{{math 10 '%' 3}}
See Number Helpers for more details.

numberFormat

Formats numbers with control over style, decimal places, and locale. Parameters:
  • First parameter: Number to format
  • Second parameter (optional): Format type (integer, currency, percent) or format string
  • Third parameter (optional): Locale string
  • maximumFractionDigits: Maximum decimal places
  • minimumFractionDigits: Minimum decimal places
  • maximumIntegerDigits: Maximum integer digits
  • minimumIntegerDigits: Minimum integer digits
  • groupingUsed: Enable/disable digit grouping (default true)
  • roundingMode: Rounding mode (up, down, half_up, half_down, half_even, ceiling, floor)
Usage:
{{{numberFormat 123.4567 'currency' 'en_GB'}}}
{{{numberFormat 123.4567 'percent' 'en_GB'}}}
{{{numberFormat 123.4567 '###.000000' 'en_GB'}}}
{{{numberFormat 1234.567 maximumIntegerDigits=3 minimumFractionDigits=6}}}
{{{numberFormat 12345.678 groupingUsed=false}}}
{{{numberFormat 1.239 roundingMode='down' maximumFractionDigits=2}}}
See Number Helpers for more details.

Random Value Helpers

randomValue

Generates random strings of specified type and length. Parameters:
  • length: Length of string (required for most types)
  • type: Type of random string (required)
  • uppercase: Convert to uppercase (optional)
Types:
  • ALPHANUMERIC: Letters and numbers
  • ALPHABETIC: Letters only
  • NUMERIC: Numbers only
  • ALPHANUMERIC_AND_SYMBOLS: Letters, numbers, and symbols
  • HEXADECIMAL: Hex characters (0-9, A-F)
  • UUID: UUID format (length not needed)
Usage:
{{randomValue length=33 type='ALPHANUMERIC'}}
{{randomValue length=12 type='ALPHANUMERIC' uppercase=true}}
{{randomValue length=55 type='ALPHABETIC'}}
{{randomValue length=27 type='ALPHABETIC' uppercase=true}}
{{randomValue length=10 type='NUMERIC'}}
{{randomValue length=5 type='ALPHANUMERIC_AND_SYMBOLS'}}
{{randomValue length=5 type='HEXADECIMAL' uppercase=true}}
{{randomValue type='UUID'}}
See Random Values for more details.

randomInt

Generates random integers with optional bounds. Parameters:
  • lower: Lower bound (optional)
  • upper: Upper bound (optional)
Usage:
{{randomInt}}
{{randomInt lower=5 upper=9}}
{{randomInt upper=54323}}
{{randomInt lower=-24}}
See Random Values for more details.

randomDecimal

Generates random decimal numbers with optional bounds. Parameters:
  • lower: Lower bound (optional)
  • upper: Upper bound (optional)
Usage:
{{randomDecimal}}
{{randomDecimal lower=-10.1 upper=-0.9}}
{{randomDecimal upper=12.5}}
{{randomDecimal lower=-24.01}}
See Random Values for more details.

pickRandom

Randomly selects a value from parameters or collection. Parameters:
  • First parameter: Collection (optional) or first value
  • Additional parameters: More values to choose from
  • count: Number of unique items to select (optional)
Usage:
{{pickRandom '1' '2' '3'}}
{{pickRandom numberList}}
{{pickRandom 1 2 3 4 5 count=3}}
See Random Values for more details.

random

Generates random test data using Faker library. Parameters:
  • First parameter: Faker key (e.g., ‘Name.firstName’, ‘Address.city’)
Usage:
{{random 'Name.firstName'}}
{{random 'Name.lastName'}}
{{random 'Internet.emailAddress'}}
{{random 'Address.city'}}
{{random 'PhoneNumber.phoneNumber'}}
See Generate Test Data for the complete list of available keys.

JSON Helpers

jsonPath

Extracts values from JSON documents using JSONPath expressions. Parameters:
  • First parameter: JSON string or object
  • Second parameter: JSONPath expression
Usage:
{{jsonPath request.body '$.outer.inner'}}
{{jsonPath request.body '$.things[0].id'}}
See Working with JSON for more details.

jsonArrayAdd

Appends elements to a JSON array. Parameters:
  • First parameter: Existing array
  • Second parameter (optional): Item to add
  • maxItems: Maximum array size (optional)
  • flatten: Flatten nested arrays (optional)
  • jsonPath: Path to nested array (optional)
Usage:
{{jsonArrayAdd existingArray newItem}}

{{#jsonArrayAdd existingArray}}
{
  "id": 321,
  "name": "sam"
}
{{/jsonArrayAdd}}

{{#jsonArrayAdd existingArray maxItems=2}}
{
  "id": 456,
  "name": "bob"
}
{{/jsonArrayAdd}}

{{#jsonArrayAdd existingArray flatten=true}}
[
  {
    "id": 456,
    "name": "bob"
  }
]
{{/jsonArrayAdd}}

{{jsonArrayAdd existingArray itemToAdd jsonPath='$[0].names'}}
See Working with JSON for more details.

jsonRemove

Removes elements from JSON arrays or keys from objects using JSONPath. Parameters:
  • First parameter: JSON object or array
  • Second parameter: JSONPath expression
Usage:
{{jsonRemove existingArray '$.[?(@.id == 123)]'}}
{{jsonRemove existingObject '$.name'}}
See Working with JSON for more details.

jsonMerge

Merges two JSON objects recursively. Parameters:
  • First parameter: Base object
  • Second parameter (optional): Object to merge
  • removeNulls: Remove null-valued attributes (optional)
Usage:
{{jsonMerge object1 object2}}

{{#jsonMerge object1}}
{
  "name": "Robert",
  "nickname": "Bob"
}
{{/jsonMerge}}

{{#jsonMerge object1 removeNulls=true}}
{
  "removeMe": null
}
{{/jsonMerge}}
See Working with JSON for more details.

formatJson

Formats JSON in pretty or compact style. Parameters:
  • First parameter (optional): JSON to format
  • format: Style (pretty or compact, defaults to pretty)
Usage:
{{formatJson object1}}
{{formatJson object1 format='compact'}}

{{#formatJson}}
{"id": 456, "name": "Robert"}
{{/formatJson}}
See Working with JSON for more details.

parseJson

Parses JSON string into object and assigns to variable. Parameters:
  • First parameter: JSON string or variable name
  • Second parameter (optional): Variable name to assign
Usage:
{{#parseJson 'newVariableName'}}
    [ "shoes", "socks" ]
{{/parseJson}}

{{parseJson inputString 'newVariableName'}}
See Working with JSON for more details.

toJson

Converts any object to JSON string. Parameters:
  • First parameter: Object to convert
Usage:
{{toJson (array 1 2 3)}}
See Working with JSON for more details.

XML Helpers

xPath

Extracts values or sub-documents from XML using XPath 1.0 expressions. Parameters:
  • First parameter: XML string
  • Second parameter: XPath expression
Usage:
{{{xPath request.body '/outer/inner/text()'}}}
{{{xPath request.body '/outer/inner/@id'}}}
See Working with XML for more details.

soapXPath

Convenience helper for extracting values from SOAP body elements. Parameters:
  • First parameter: SOAP XML string
  • Second parameter: XPath expression (relative to SOAP body)
Usage:
{{{soapXPath request.body '/a/test/text()'}}}
See Working with XML for more details.

formatXml

Formats XML in pretty or compact style. Parameters:
  • First parameter (optional): XML to format
  • format: Style (pretty or compact, defaults to pretty)
Usage:
{{formatXml object1}}
{{formatXml object1 format='compact'}}

{{#formatXml}}
<foo><bar>wh</bar></foo>
{{/formatXml}}
See Working with XML for more details.

Cryptographic Helpers

hash

Creates cryptographic hashes of text. Parameters:
  • algorithm: Hashing algorithm (required)
  • encoding: Output encoding (hex or base64, required)
Algorithms:
  • sha-1, sha-224, sha-256, sha-384, sha-512
  • sha3-224, sha3-256, sha3-384, sha3-512
  • md2, md5
Usage:
{{#hash algorithm='sha-256' encoding='hex'}}text to hash{{/hash}}
{{#hash algorithm='md5' encoding='base64'}}text to hash{{/hash}}
See Cryptographic Helpers for more details.

JWT Helpers

jwt

Generates signed JSON Web Tokens. Parameters:
  • alg: Signing algorithm (HS256 or RS256, defaults to HS256)
  • maxAge: Expiry duration (e.g., ‘12 days’)
  • exp: Expiry date (alternative to maxAge)
  • nbf: Not before date (optional)
  • iss: Issuer claim (optional)
  • aud: Audience claim (optional)
  • sub: Subject claim (optional)
  • Any additional parameters become custom claims
Usage:
{{{jwt maxAge='12 days'}}}
{{{jwt exp=(parseDate '2040-02-23T21:22:23Z')}}}
{{{jwt nbf=(parseDate '2018-02-23T21:22:23Z')}}}
{{{jwt iss='https://jwt-example.wiremockapi.cloud/'}}}
{{{jwt aud='https://jwt-target.wiremockapi.cloud/'}}}
{{{jwt sub='jonsmith'}}}
{{{jwt
    isAdmin=true
    quota=23
    score=0.96
    email='jonsmith@example.com'
}}}
{{{jwt alg='RS256'}}}
See JWT Web Tokens for more details.

jwks

Generates JSON Web Key Set for RS256 public keys. Usage:
{{{jwks}}}
See JWT Web Tokens for more details.

Dynamic State Helpers

state

Retrieves a state value stored in a context by its key. Parameters:
  • First parameter: Key name (required)
  • context: Context name (optional, uses default context if not specified)
Usage:
{{state 'itemName'}}
{{state 'userId' context='v1_users'}}
{{state 'id' context=collectionContext}}
See Dynamic State Basics for more details.

stateContext

Sets the default context for all state helpers within its block, avoiding repetition. Parameters:
  • First parameter: Context name or expression (required)
Usage:
{{#stateContext request.headers.x-test-id}}
  The current itemName is {{state 'itemName'}}
  The current userId is {{state 'userId'}}
{{/stateContext}}

{{#stateContext collectionContext}}
  {{#formatJson}}
    {{state id}}
  {{/formatJson}}
{{/stateContext}}
See Dynamic State Basics for more details.

listState

Returns all state values within a given context as a collection. Parameters:
  • First parameter: Context name or expression (required)
Usage:
{{listState request.headers.x-test-id}}
{{listState collectionContext}}

{{#formatJson}}
{
  "users" : [{{#arrayJoin ',' (listState collectionContext) as |item|}}
    {{jsonPath item '$.user'}}
  {{/arrayJoin}}]
}
{{/formatJson}}

{{#formatJson}}
  [{{arrayJoin ',' (listState collectionContext)}}]
{{/formatJson}}
See Dynamic State Basics for more details.

Collection and Utility Helpers

assign

Creates a string variable for later use. Parameters:
  • First parameter: Variable name
Usage:
{{#assign 'myCapitalisedQuery'}}{{capitalize request.query.search}}{{/assign}}

Capitalised query: {{myCapitalisedQuery}}
See Miscellaneous Helpers for more details.

val

Accesses values with default fallback, maintains type (unlike assign). Parameters:
  • First parameter: Value or expression
  • or/default: Default value if first parameter is absent
  • assign: Variable name to assign result
Usage:
{{val request.query.search or='default'}}
{{val request.query.search default='default'}}
{{val request.query.search}}
{{val request.query.search or='default' assign='myVar'}}
{{val request.query.search assign='myVar'}}
{{val (array 1 2 3) default='123'}}
{{val 'value for myVar' assign='myVar'}}{{myVar}}
{{val 10 assign='myVar'}}{{#lt myVar 20}}Less Than{{else}}More Than{{/lt}}
See Miscellaneous Helpers for more details.

size

Returns the size of a string, list, or map. Parameters:
  • First parameter: String, list, or map
Usage:
{{size 'abcde'}}
{{size request.query.things}}
See Miscellaneous Helpers for more details.

with

Creates a nested scope for accessing object properties. Parameters:
  • First parameter: Object
Usage:
{{#with myObject}}
  ID: {{{id}}}
  Position: {{{position}}}
{{/with}}
See Miscellaneous Helpers for more details.

range

Generates an array of integers between two bounds. Parameters:
  • First parameter: Lower bound (inclusive)
  • Second parameter: Upper bound (exclusive)
Usage:
{{range 3 8}}
{{range -2 2}}
{{#each (range 0 (randomInt lower=1 upper=10)) as |index|}}
id: {{index}}
{{/each}}
See Miscellaneous Helpers for more details.

array

Creates an array containing the specified values. Parameters:
  • Any number of values
Usage:
{{array 1 'two' true}}
{{array}}
See Miscellaneous Helpers for more details.

arrayAdd

Adds an element to an array at specified position. Parameters:
  • First parameter: Array
  • Second parameter: Element to add
  • position: Index, start, or end (optional, defaults to end)
Usage:
{{arrayAdd (array 1 'three') 2 position=1}}
{{arrayAdd (array 1 'three') 2 position='start'}}
{{arrayAdd (array 1 'three') 2 position='end'}}
{{arrayAdd (array 1 'three') 2}}
See Miscellaneous Helpers for more details.

arrayRemove

Removes an element from an array at specified position. Parameters:
  • First parameter: Array
  • position: Index, start, or end (optional, defaults to end)
Usage:
{{arrayRemove (array 1 2 'three') position=1}}
{{arrayRemove (array 1 2 'three') position='start'}}
{{arrayRemove (array 1 2 'three') position='end'}}
{{arrayRemove (array 1 2 'three')}}
See Miscellaneous Helpers for more details.

arrayJoin

Concatenates array values with a separator. Parameters:
  • First parameter: Separator string
  • Additional parameters: Values or array to join
  • prefix: String to prepend (optional)
  • suffix: String to append (optional)
Usage:
{{arrayJoin ',' (array 'One' 'Two' 'Three')}}
{{arrayJoin ' - ' 'a' 'b' 'c'}}
{{arrayJoin ', ' (range 1 5)}}
{{arrayJoin ',' (array 'One' 'Two' 'Three') prefix='[' suffix=']'}}

{{#arrayJoin ',' myThings as |item|}}
{
  "name{{item.id}}": "{{item.name}}"
}
{{/arrayJoin}}

{{#arrayJoin ',' myThings prefix='[' suffix=']' as |item|}}
{
  "name{{item.id}}": "{{item.name}}"
}
{{/arrayJoin}}
See Miscellaneous Helpers for more details.

hostname

Returns the hostname of the mock API. Usage:
{{hostname}}

Conditional Logic Helpers

if

Evaluates condition and renders block if true. Usage:
{{#if showDetails}}
  <div id="details">...</div>
{{/if}}

{{#if showVariantA}}
  <div id="var-a">...</div>
{{else if showVariantB}}
  <div id="var-b">...</div>
{{else}}
  <div id="default">...</div>
{{/if}}
See Conditional Logic for more details.

unless

Evaluates condition and renders block if false. Usage:
{{#unless hideDetails}}
  <div id="details">...</div>
{{/unless}}
See Conditional Logic for more details.

eq

Tests equality. Parameters:
  • First parameter: Left value
  • Second parameter: Right value
Usage:
{{#eq name 'Dan'}}
  <div id="dan">...</div>
{{/eq}}

{{#if (eq name 'Dan')}}
  <div id="dan">...</div>
{{/if}}
See Conditional Logic for more details.

neq

Tests inequality. Parameters:
  • First parameter: Left value
  • Second parameter: Right value
Usage:
{{#neq name 'Jeff'}}...{{/neq}}
See Conditional Logic for more details.

gt

Tests greater than. Parameters:
  • First parameter: Left value
  • Second parameter: Right value
Usage:
{{#gt itemCount 3}}...{{/gt}}
See Conditional Logic for more details.

gte

Tests greater than or equal to. Parameters:
  • First parameter: Left value
  • Second parameter: Right value
Usage:
{{#gte itemCount 3}}...{{/gte}}
See Conditional Logic for more details.

lt

Tests less than. Parameters:
  • First parameter: Left value
  • Second parameter: Right value
Usage:
{{#lt itemCount 3}}...{{/lt}}
See Conditional Logic for more details.

lte

Tests less than or equal to. Parameters:
  • First parameter: Left value
  • Second parameter: Right value
Usage:
{{#lte itemCount 3}}...{{/lte}}
See Conditional Logic for more details.

and

Logical AND operation. Parameters:
  • Multiple boolean expressions
Usage:
{{#and (lt itemCount 10) (gt itemCount 5)}}...{{/and}}
See Conditional Logic for more details.

or

Logical OR operation. Parameters:
  • Multiple boolean expressions
Usage:
{{#or (eq itemCount 1) (eq itemCount 2)}}...{{/or}}
See Conditional Logic for more details.

not

Logical NOT operation. Parameters:
  • One boolean expression
Usage:
{{#not (eq itemCount 1)}}...{{/not}}
See Conditional Logic for more details.

contains

Tests if string or array contains a value. Parameters:
  • First parameter: String or array
  • Second parameter: Value to find
Usage:
{{#if (contains 'abcde' 'abc')}}YES{{/if}}
{{#if (contains (array 'a' 'b' 'c') 'a')}}YES{{/if}}

{{#contains 'abcde' 'abc'}}YES{{/contains}}
{{#contains (array 'a' 'b' 'c') 'a'}}YES{{/contains}}
See Conditional Logic for more details.

matches

Tests if string matches a regular expression. Parameters:
  • First parameter: String to test
  • Second parameter: Regular expression pattern
Usage:
{{#if (matches '123' '[0-9]+')}}YES{{/if}}

{{#matches '123' '[0-9]+'}}YES{{/matches}}
See Conditional Logic for more details.

Iteration Helpers

each

Iterates over collections (arrays or objects). Usage:
{{#each request.query.things as |thing|}}
  thing: {{{thing}}}
{{/each}}

{{#each (jsonPath request.body '$.things') as |value key|}}
  {{{key}}}={{{value}}}
{{/each}}

{{#each (range 0 5) as |index|}}
  {{@index}}: {{index}}
  {{#if @first}}First!{{/if}}
  {{#if @last}}Last!{{/if}}
{{/each}}
Special variables:
  • @index: Current iteration index (zero-based)
  • @first: True if first iteration
  • @last: True if last iteration
See Conditional Logic for more details.