The eq helper compares two input values and returns true if they are equal, using loose equality (type coercion allowed). Use it when comparing values that may differ in type but represent the same value.
{{eq firstVal secondVal}}
-
firstVal (required): the first value to compare
-
secondVal (required): the second value to compare
Tip
Returns boolean true if values are equal under loose equality, else false.
Compare numbers and strings
{{eq record.a record.b}}
{{eq record.a record.c}}
{{eq record.a record.d}}
Input:
{
"record": {
"a": 5,
"b": 5,
"c": "5",
"d": 3
}
}
Output:
true true false
A conditional usage example
{{#if (eq record.role "admin")}}
Has admin access
{{else}}
Standard access
{{/if}}
Input:
{ "record": { "role": "admin" } }
Output:
Has admin access
Tip
-
Uses loose equality (
==) —"5"equals5. -
Commonly used in conditional logic helpers (e.g.,
#if,#unless) to simplify comparisons.