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
  • Directory Structure
  • Summary
  • Basic Syntax
  • Displaying Integration Data
  • Displaying Component Data
  1. Building an Integration
  2. Customizing the Overlay Window

Templates

Use the Handlebars templating language to customize the look of your integration.

PreviousCustomizing the Overlay WindowNextConditionals

Last updated 3 years ago

Directory Structure

sample-integration/
├── templates/
|   └── sample-integration.hbs

Summary

Integration templates allow you to customize how data returned from your integration is rendered in the details section of your integration. Templates are written using syntax which enhances HTML by providing intuitive syntax for mixing static HTML content with dynamic integration content inside curly braces {{ }}. Handlebars also provides basic programming logic such as if/then/else statements and loops.

To begin you should create a template file with an .hbs extension. If you are following the recommended directory layout then the file should be placed in templates/your-integration.hbs. See the for more information.

After creating the template file make sure to configure your integration to use the template and associated component by .

Basic Syntax

Polarity Integrations use Ember Handlebars syntax. The syntax is covered in the official Ember templates guide:

Displaying Integration Data

Integrations return an array of result objects. Each result object is rendered into a block using the template you specify in config.js or the default template which simply renders the data into a table. When accessing the integration data in your template the result object is accessed through the block property.

You can then use the curly brace syntax {{ }} to render the dynamic data.

Assuming the result object returned from the integration has the following properties:

{
    "entity": entityObject,
    "data": {
        "summary": ['Tag 1', 'Tag2'],
        "details": {
            "firstName": "John",
            "lastName": "Smith"
        }
    }
}

You would display the firstName and lastName in your template like this:

<div>
  {{block.data.details.firstName}} {{block.data.details.lastName}}
</div>

Displaying Component Data

Variables that you define in a custom component can also be accessed in your templates. In this case access the variable directly without using the block object.

components/block.js
polarity.export = PolarityComponent.extend({
    firstName: "John",
    lastName: "Smith"
});

For example, if you define the firstName and lastName properties in your component file you can access those properties directly in your template to display them.

<div>
  {{firstName}} {{lastName}}
</div>

This would result in the following HTML

<div>
   John Smith
</div>

Ember Handlebars
directory layout guide
specifying the template file in your config.js file
Ember Templates Guide