Handlebars Helpers
If Eq
Conditionally renders content when two values are strictly equal
The if_eq helper combines an equality comparison with an if block. It renders the block content when the first value is strictly equal to the second value, and renders the else block when they are not equal.
This helper uses JavaScript strict equality (===), so both the value and the type must match.
Uses
- Use when you want a concise equality condition without nesting
eqinsideif - Use to render one of two outputs based on an exact string, number, or boolean match
Usage
Helper name : if_eq
eg.
{{#if_eq stub.state "done"}}yes{{else}}no{{/if_eq}}
Examples
Example definition:
Action context:
Substituted definition
Example With Else
Example definition:
Action context:
Substituted definition
Strict Equality
Because if_eq uses strict equality, values with different types do not match.
If stub.data.customer.count is the number 1, this does not match the string "1".
See also: eq