Comparison Helpers API reference for comparison template helpers git-compare Guide

Comparison Helpers

Comparison helpers provide utilities for comparing values in templates.

Functions

not

Checks negation (!).

Template Syntax

{#if not someCondition}
someCondition is not true
{/if}

JavaScript Syntax

not(a)

is

Checks equality (==).

Template Syntax

{#if is valueA valueB}
Values are equal
{/if}

JavaScript Syntax

is(a, b)

Parameters

NameTypeDescription
aanyFirst value to compare
banySecond value to compare

Returns

boolean - True if values are equal, false otherwise.

Example

is(5, "5") // true

notEqual

Checks inequality (!=).

Template Syntax

{#if notEqual valueA valueB}
Values are not equal
{/if}

JavaScript Syntax

notEqual(a, b)

Parameters

NameTypeDescription
aanyFirst value to compare
banySecond value to compare

Returns

boolean - True if values are not equal, false otherwise.

Example

not(5, "6") // true

isExactly

Checks strict equality (===).

Template Syntax

{#if isExactly valueA valueB}
Values are strictly equal
{/if}

JavaScript Syntax

isExactly(a, b)

Parameters

NameTypeDescription
aanyFirst value to compare
banySecond value to compare

Returns

boolean - True if values are strictly equal, false otherwise.

Example

isExactly(5, 5) // true
isExactly(5, "5") // false

isNotExactly

Checks strict inequality (!==).

Template Syntax

{#if isNotExactly valueA valueB}
Values are strictly not equal
{/if}

JavaScript Syntax

isNotExactly(a, b)

Parameters

NameTypeDescription
aanyFirst value to compare
banySecond value to compare

Returns

boolean - True if values are strictly not equal, false otherwise.

Example

isNotExactly(5, "5") // true

greaterThan

Checks if a > b.

Template Syntax

{#if greaterThan numberA numberB}
A is greater than B
{/if}

JavaScript Syntax

greaterThan(a, b)

Parameters

NameTypeDescription
anumberFirst number to compare
bnumberSecond number to compare

Returns

boolean - True if a is greater than b, false otherwise.

Example

greaterThan(10, 5) // true

lessThan

Checks if a < b.

Template Syntax

{#if lessThan numberA numberB}
A is less than B
{/if}

JavaScript Syntax

lessThan(a, b)

Parameters

NameTypeDescription
anumberFirst number to compare
bnumberSecond number to compare

Returns

boolean - True if a is less than b, false otherwise.

Example

lessThan(5, 10) // true

greaterThanEquals

Checks if a >= b.

Template Syntax

{#if greaterThanEquals numberA numberB}
A is greater than or equal to B
{/if}

JavaScript Syntax

greaterThanEquals(a, b)

Parameters

NameTypeDescription
anumberFirst number to compare
bnumberSecond number to compare

Returns

boolean - True if a is greater than or equal to b, false otherwise.

Example

greaterThanEquals(10, 10) // true

lessThanEquals

Checks if a <= b.

Template Syntax

{#if lessThanEquals numberA numberB}
A is less than or equal to B
{/if}

JavaScript Syntax

lessThanEquals(a, b)

Parameters

NameTypeDescription
anumberFirst number to compare
bnumberSecond number to compare

Returns

boolean - True if a is less than or equal to b, false otherwise.

Example

lessThanEquals(5, 5) // true