Simplifying handlebars expressions

Built-in tools that simplify entering handlebars expressions.

To personalize content in Airship, use HandlebarsHandlebars is Airship’s templating language for personalization. Handlebars expressions use double curly braces wrapped around a content template, ranging from a simple variable, e.g., {{first_name}} to complex evaluations of personalization data. syntax to create Merge FieldsA variable in your message or template that you want to populate with a personalized value for each member of the audience. Merge fields use Handlebars syntax — {{merge_field}}. that are populated with data at send time. You can also create logic statements that conditionally render content. We provide tools to simplify adding and formatting these expressions.


When entering content in message (including SurveysQuestion-and-answer experiences used to collect and aggregate feedback or generate a net promoter score. They are cached on users’ devices and displayed when your users meet certain conditions within your app, such as viewing a particular screen or opening the app a certain number of times. and ScenesMulti-screen experiences that are cached on users’ devices and displayed when your users meet certain conditions within your app, such as viewing a particular screen or opening the app a certain number of times. ) and template text fields, click </> to start creating merge fields or logic statements for the Text and Number AttributesMetadata that you can use for audience segmentation. Attributes differ from tags in that when evaluating users with attributes, Airship uses operators, e.g., equals, less than/greater than, contains, before/after, to determine whether or not to target a user. Supported attribute types are TEXT, NUMBER, and DATE. in your project.

This option is available for most text fields, such as message body, button labels, URLs, Custom KeysAdditional key-value pairs in your push notification payload for use by custom code in your app. You can use custom keys to pass additional campaign identifiers for analytics, pass user information to the device, control the look and feel of the app, provide image links, etc. , and pasted or uploaded HTML in the Interactive editor.

Merge fields

When entering content in message and template text fields:

  1. Click </> and select Merge field.
  2. Search for an attribute and select from the list. You can search by attribute name or ID.
  3. Enter a default value that will be used if the merge field is empty, OR, if you want to allow empty values, leave the default value blank and check the Allow empty values checkbox.
  4. Click Insert.

Your expression is inserted in the text field in the format {{attribute_id}} or {{$def attribute_id "default_value"}}. You can edit the "default_value" or delete the entire handlebar string to remove it.

Logic statements

The first statement you add is an if, which means your content is rendered in your message if the statement is true. You can then add else if and else statements. Each additional statement is a condition that builds on the preceding one, and all are formatted as a single expression.

  • Statement 1: if — The specified text is displayed if the statement is true. Only this initial statement is required.

  • Statement 2: else if — The specified text is displayed if statement 1 is false and statement 2 is true. You can add multiple else if statements.

  • Statement 3: else — The specified text is displayed if all preceding statements are false. You can add an else statement without adding any else if statements.

See also: Handlebars Reference: If/Else Statements.


When entering content in message and template text fields:

  1. Click </> and select Logic statement.
  2. Search for an attribute and select from the list. You can search by attribute name or ID.
  3. Select the operator you want to use, and enter a value. Available operators depend on the attribute type (Text or Number). As you add and edit statements, the code output that will be inserted in your message displays at the bottom of the window.
  4. Click Add content, enter the content you want to display in the message when the statement is true, then click Apply.
  5. (Optional) Click   to add else and/or else if conditions and complete previous steps.
  6. Click Insert.

Your expression is inserted in the text field. You can edit the display text for each statement or delete the entire handlebar string to remove it.

Example logic statement

In this example, we want to show existing loyalty program members a discount code and non-members a signup message. We will build this expression based on attribute loyalty_status.

First set the attribute to equal value member.

Then enter content Thank you for being a loyalty member. Use code UNDOCK to get an extra 10% off this purchase..

Next add an else statement, for users for whom the first statement is false, and enter the content those users will see instead: Like great savings? Sign up to become a loyalty member today!.

The code updates as you add and edit statements. Click Insert to add the expression to your message.