Handlebars - Nesting Helpers

Table of Contents

Nesting Helpers allow you to compare values in the following ways:

  • Nesting or Helpers - Create fallback chains by nesting multiple or helpers
    • Example: <!– Triple fallback -->
      {{or [Preferred-Name] (or [First-Name] "Friend")}}
      <!-- Even more complex -->
      {{or [Nickname] (or [Display-Name] (or [First-Name] "Valued Customer"))}}
  • Nesting or within and - Check multiple conditions where some have callback
    • Example: {{#if (and (or [First-Name] [Last-Name]) [Email-Verified])}}
      <p>Your profile has a name and verified email!</p>
      {{/if}}
  • Nesting comparisons with and - Combine multiple comparison helpers
    • Example: <!-- VIP customers in the US with high balance -->
      {{#if (and (eq [Country] "United States") (eq [Membership-Level] "VIP") (gt [Account-Balance] 1000))}}
      <p>You qualify for premium free shipping!</p>
      {{/if}}
  • Nesting comparisons with or (using and) - Check if ANY multiple conditions are true
    • Example: <!-- Show offer if Gold OR Platinum OR high loyalty points -->
      {{#if (or (eq [Membership-Level] "Gold") (or (eq [Membership-Level] "Platinum") (gt [Loyalty-Points] 5000)))}}
      <p>Special offer available!</p>
      {{/if}}
The Pinpointe Playbook