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
| argument | type | description |
|---|---|---|
| property | string | The data bound property to check |
| value | any | The 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
| argument | type | description |
|---|---|---|
| field1 | string | Left-hand value |
| operator | string | Comparison operator (see table below) |
| field2 | string | Right-hand value |
| operator | description |
|---|---|
| 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
| argument | type | description |
|---|---|---|
| value | any | The value to check |
| lowerBound | any | Lower boundary (inclusive) |
| upperBound | any | Upper boundary (inclusive) |
| fieldType | string | Optional: 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
| argument | type | description |
|---|---|---|
| property | string | The data bound property to test |
| value | string | Comma-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
| argument | type | description |
|---|---|---|
| array | array | The array to check |
| property | string | The property on each item to check |
| value | any | The 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
| argument | type | description |
|---|---|---|
| array | array | The array to check |
| property | string | The property on each item to compare |
| operator | string | Comparison operator (see table below) |
| value | any | The value to compare against |
| fieldType | string | Optional: set to number for numeric comparison |
| operator | description |
|---|---|
| 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
| argument | type | description |
|---|---|---|
| property | string | The property to check |
| allowEmpty | string | Optional: 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
| argument | type | description |
|---|---|---|
| propertyName | string | The 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
| argument | type | description |
|---|---|---|
| property | string | The string to test |
| value | string | The search string |
| isCaseInsensitive | string | Optional: set to 'true' to ignore case |
| matchPosition | string | Optional: 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}}