Handlebars - Comparison Helpers
Table of Contents
Comparison Helpers allow you to compare values in Handlebars in a few different ways. The comparison helpers allow the handlebars to display different text depending if certain conditions are met by comparing fields to each other.
Here are examples of Comparison Helpers:
- 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}}
- Example: {{#if (eq [Country] "United States")}}
- Syntax: {{#if (and value1 value2 value3 ...)}}
- 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}}
- Example: {{#if (ne [Membership-Level] "VIP")}}
- Syntax: {{#if (ne value1 value2)}}
- 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}}
- Example: {{#if (gt [Age] 21)}}
- Syntax: {{#if (gt value1 value2)}}
- 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}}
- Example: {{#if (lt [Days-Until-Expiration] 7)}}
- Syntax: {{#if (lt value1 value2)}}
Pinpointe Newsletter
Join the newsletter to receive the latest updates in your inbox.