Built-in Helpers

Handlebars includes a collection of useful built-in helpers to assist with displaying data

Truth Helpers

A set of helpers is made available known as ember-truth-helpers. These helpers allow you to include additional logic within your handlebar templates such as and, or, gt, lt etc. Truth helpers are used in conjunction with conditionals.

Assume we are working with the following return data from our integration which includes the numResults, severity and confidence values.

// Result Object Returned from integration
  "entity": entityObj,
  "data": {
    "summary": ['Tag 1'],
    "details": {
      "numResults": 10,
      "severity": 75,
      "confidence": 50,
      "source": "Threat Intel Report"

We can make use of the gt (greater than) helper to only display data if there are results.

{{#if (gt block.data.details.numResults 0)}}
    There are results

You can combine multiple truth helpers to construct more complex conditional statements. For example, if we only want to display data if the severity is greater than 70 and the confidence is greater than or equal to 50 we can do the following.

{{#if (and (gt block.data.details.severity 70)(gte block.data.details.confidence 50))}}

If you find yourself writing extremely complex logic using the truth helpers you will ofentimes want to convert the logic into a single computed property.

For more information on how to use these helpers please see the official documentation for Ember Truth Helpers.

Date Helpers

The excellent ember-moment helpers are available in integrations to assist with formatting dates. You can find more information about how to use ember-moment from the ember-moment website:


Last updated