Comparison Helpers allow you to compare values in the following ways:
- eq - Checks if two values are equal
- Syntax: {{#if (and value1 value2 value3 ...)}}
- Example:
{{#if (eq [Country] "United States")}} <p>Free shipping on all orders!</p> {{else}} <p>International shipping rates apply.</p> {{/if}}
- ne - Checks if two values are not equal
- Syntax: {{#if (ne value1 value2)}}
- Example:
{{#if (ne [Membership-Level] "VIP")}} <p>Upgrade to VIP to unlock premium content!</p> {{/if}}
- gt - Checks if a numeric value is greater than another; only works with numeric values.
- Syntax: {{#if (gt value1 value2)}}
- Example:
{{#if (gt [Age] 21)}} <p>Check out our wine collection!</p> {{/if}}
- lt - Checks if a numeric value is less than another
- Syntax: {{#if (lt value1 value2)}}
- Example:
{{#if (lt [Days-Until-Expiration] 7)}} <p><strong>URGENT:</strong> Your membership expires in {{[Days-Until-Expiration]}} days!</p> {{/if}}
Here are some examples,
For more detailed information on Handlebars, please consult the appropriate article below: