Skip to main content

Conditional logic

Logic helpers let you conditionally include or exclude template content based on field values, comparisons, array membership, and string matching.

ifEquals

Tests whether a property equals a specific value. Case sensitive.

ifEquals property value
argumenttypedescription
propertystringThe data bound property to check
valueanyThe value to compare against

Example

{{#ifEquals vessel.name 'Ocean Star'}}
Welcome back, Ocean Star!
{{else}}
Unknown vessel.
{{/ifEquals}}

ifCompares

Compares two values using a relational operator. Comparison is text-based unless both values are numeric strings.

ifCompares field1 operator field2
argumenttypedescription
field1stringLeft-hand value
operatorstringComparison operator (see table below)
field2stringRight-hand value
operatordescription
eq or == or =field1 equals field2
noteq or != or <>field1 does not equal field2
lt or <field1 is less than field2
lteq or <=field1 is less than or equal to field2
gt or >field1 is greater than field2
gteq or >=field1 is greater than or equal to field2

Example

{{#ifCompares cargo.tonnage '>' '50000'}}
Heavy cargo — notify port authority.
{{/ifCompares}}

ifBetween

Tests whether a value falls within a range (both bounds inclusive).

ifBetween value lowerBound upperBound fieldType
argumenttypedescription
valueanyThe value to check
lowerBoundanyLower boundary (inclusive)
upperBoundanyUpper boundary (inclusive)
fieldTypestringOptional: set to number for numeric comparison

Example

{{#ifBetween cargo.tonnage '10000' '75000' 'number'}}
Tonnage within standard range.
{{else}}
Tonnage outside standard range.
{{/ifBetween}}

ifInArray

Tests whether a property value is present in a comma-separated list. Case sensitive.

ifInArray property value
argumenttypedescription
propertystringThe data bound property to test
valuestringComma-separated list of values to check against

Example

{{#ifInArray portcall.portName 'Amsterdam,Rotterdam,Antwerp'}}
ARA range port confirmed.
{{else}}
Port outside ARA range.
{{/ifInArray}}

ifAny

Tests whether any item in an array has a property that matches a specific value.

ifAny array property value
argumenttypedescription
arrayarrayThe array to check
propertystringThe property on each item to check
valueanyThe value to match against

Example

{{#ifAny portcall.vessels 'cargoType' 'LNG'}}
LNG handling procedures apply.
{{/ifAny}}

ifAnyCompares

Tests whether any item in an array has a property that satisfies a comparison.

ifAnyCompares array property operator value fieldType
argumenttypedescription
arrayarrayThe array to check
propertystringThe property on each item to compare
operatorstringComparison operator (see table below)
valueanyThe value to compare against
fieldTypestringOptional: set to number for numeric comparison
operatordescription
eq or == or =Property equals value
noteq or != or <>Property does not equal value
lt or <Property is less than value
lteq or <=Property is less than or equal to value
gt or >Property is greater than value
gteq or >=Property is greater than or equal to value

Example

{{#ifAnyCompares shipments 'tonnage' '>=' '50000' 'number'}}
At least one shipment meets minimum tonnage threshold.
{{else}}
No shipments meet the minimum tonnage threshold.
{{/ifAnyCompares}}

ifIsNotNull

Tests whether a property is not null. Optionally treats empty strings as null.

ifIsNotNull property allowEmpty
argumenttypedescription
propertystringThe property to check
allowEmptystringOptional: set to 'true' to treat empty strings as null

Example

{{#ifIsNotNull portcall.agent}}
Agent on record: {{portcall.agent}}
{{else}}
No agent assigned.
{{/ifIsNotNull}}

{{#ifIsNotNull portcall.agent 'true'}}
Agent on record: {{portcall.agent}}
{{else}}
No agent assigned (empty counts as null).
{{/ifIsNotNull}}

ifPropertyExists

Tests whether a property key exists on an object, regardless of its value (even null, 0, false, or empty string all pass this check).

ifPropertyExists propertyName
argumenttypedescription
propertyNamestringThe property name to look for

Example

{{#ifPropertyExists 'eta'}}
ETA field is present.
{{else}}
ETA field is missing from this record.
{{/ifPropertyExists}}

Use this when you need to distinguish between a field that is absent and one that simply has a null or empty value.


ifStringIsMatch

Tests whether a string matches a value, with options for case sensitivity and match position. Case sensitive by default.

ifStringIsMatch property value isCaseInsensitive matchPosition
argumenttypedescription
propertystringThe string to test
valuestringThe search string
isCaseInsensitivestringOptional: set to 'true' to ignore case
matchPositionstringOptional: starts, ends, exact, or omit for substring match

Example

{{#ifStringIsMatch vessel.name 'Nordic'}}
Nordic fleet vessel detected.
{{else}}
Vessel name does not contain 'Nordic'.
{{/ifStringIsMatch}}

{{#ifStringIsMatch portcall.portName 'hamburg' 'true' 'ends'}}
Destination is Hamburg.
{{/ifStringIsMatch}}