When adding Handlebars, there are some Best Practices to keep in mind:


  1. Always provide fallbacks: Use default or or helpers to ensure graceful degradation when data is missing.

  2. Wrap complex variables: Any variable name with special characters (hyphens, colons, spaces) must be wrapped in square brackets:

    {{[First-Name]}}           ✓ Correct (has hyphen) {{[todaysdate:Ymd]}}       ✓ Correct (has colon) {{[subscriber-timezone]}}  ✓ Correct (has hyphen) {{First-Name}}             ✗ Wrong

    Note: Variables with underscores only (like current_day, subscriber_id) do NOT need brackets:

    {{current_day}}      ✓ Correct {{subscriber_id}}    ✓ Correct {{random_number}}    ✓ Correct
  3. Test with empty data: Ensure your templates render correctly when custom fields are empty.

  4. Use meaningful fallbacks: Instead of generic "Customer", try context-specific fallbacks:

    Hello {{or [First-Name] "Valued Member"}}!
  5. Combine helpers for complex logic: Nest helpers to create sophisticated conditional logic:

    {{#if (and (eq [Country] "US") (gt [Order-Total] 50))}}
  6. Keep comparisons data type-appropriate: Use gt and lt only with numeric values.


For more detailed information on Handlebars, please consult the appropriate article below: