LogoLogo
Enterprise GuideCommunity Edition GuideDeveloper Guide
  • Using The Polarity Developer Guide
  • Quick Start
    • What's New
    • Installing Integrations
    • Quick Start Guide
    • Learning Resources
  • Building an Integration
    • Directory Layout
    • package.json
    • Configuration File
    • Integration Main Module
      • startup
      • doLookup
        • Entity Objects
        • Result Objects
        • Error Objects
      • onDetails
      • onMessage
      • validateOptions
    • Customizing the Overlay Window
      • Templates
        • Conditionals
        • Displaying a List of Items
        • Display Object Properties
        • Built-in Helpers
        • Displaying Icons
      • Component File
        • Aliased Properties
        • Computed Properties
        • Event Hooks
      • CSS Styles
    • Vendor Javascript
      • Inserting Javascript into DOM
    • README Guide
    • Debugging Integrations
      • Web Inspector
      • Using Integration Logs
      • Testing Main Module
  • Recipes
    • Enabling User Actions
    • Throttling Lookups
    • Using Custom Entity Types
    • Custom Summary Tags
    • Creating a Tabbed Interface
    • Accessing Username of Requestor
Powered by GitBook
On this page
  • Truth Helpers
  • Date Helpers
  1. Building an Integration
  2. Customizing the Overlay Window
  3. Templates

Built-in Helpers

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

PreviousDisplay Object PropertiesNextDisplaying Icons

Last updated 5 years ago

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 .

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.

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

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.

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

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:

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

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

conditionals
computed property
Ember Truth Helpers
https://github.com/stefanpenner/ember-moment