What external libraries and modules are allowed in Experience Designer?

Orbita exposed the following libraries and modules from Experience Manager to Experience Designer.

dataforge

The dataforge library can load CSV, JSON, or arbitrary data sets; dataforge lets you analyze data, wrangle, and visualize with ease.
See npm: data-forge.

Some of the features include:

  • Import and export CSV and JSON data, arbitrary JavaScript data, and text files.

  • Many options for working with your data:

    • Filtering and sorting

    • Transformation

    • Extracting subsets

    • Grouping, aggregation, and summation

  • Great for analyzing tabular data: add, remove, transform, and generate named columns (series) of data.

  • Great for working with time-series data.

  • Your data is indexed so you can merge and aggregate it.

  • Your data is immutable! Transformations and modifications produce a new dataset.

const dataForge = require('dataforge'); dataForge.readFile('./input-data-file.csv') // Read CSV file (or JSON!)     .parseCSV()     .parseDates(["Column B"]) // Parse date columns.     .parseInts(["Column B", "Column C"]) // Parse integer columsn.     .parseFloats(["Column D", "Column E"]) // Parse float columns.     .dropSeries(["Column F"]) // Drop certain columns.     .where(row => predicate(row)) // Filter rows.     .select(row => transform(row)) // Transform the data.     .asCSV()     .writeFile("./output-data-file.csv") // Write to output CSV file (or JSON!)     .then(() => {         console.log("Done!");     })     .catch(err => {          console.log("An error occurred!");      });

handlebars

The handlebars library lets you build semantic templates effectively with no frustration. The handlebars library is compatible with mustache templates. In most cases, you can swap out the mustache with handlebars and continue using your current templates.
See npm: handlebars .

When you have a template, use the Handlebars.compile method to compile the template into a function. The generated function takes a context argument, which will be used to render the template.

var source = "<p>Hello, my name is {{name}}. I am from {{hometown}}. I have " +              "{{kids.length}} kids:</p>" +              "<ul>{{#kids}}<li>{{name}} is {{age}}</li>{{/kids}}</ul>"; var template = Handlebars.compile(source); var data = { "name" : "Alan", "hometown" : "Somewhere, TX",              "kids" : [ {"name": "Jimmy", "age": "12"}, {"name": "Sally", "age": "4"} ] }; var result = template(data);

The output appears as follows:

Hello, my name is Alan. I am from Somewhere, TX. I have 2 kids: Jimmy is 12 Sally is 4

lodash

The lodash library makes JavaScript easier by taking the hassle out of working with arrays, numbers, objects, strings, and so on.
See https://lodash.com/docs/4.17.15.

  • Iterating arrays, objects, and strings

  • Manipulating and testing values

  • Creating composite functions

The following code loops through an array and outputs the value.

moment

The moment library makes it easier to use parse, validate, manipulate, and display dates and times in JavaScript.
See Moment.js | Home.

  • Format Dates.

  • Calculate relative time.

  • Use calendar time.

  • Format time.

The following code returns the date of the day that is # days from today.

momentTimezone

The momentTimezone library makes it easier to parse and display dates in any time zones.
See Moment Timezone | Home .

  • Format Dates in any time zone.

  • Convert Dates between time zones.

The following code returns New York time.

orbitaUtil

The orbitaUtil library contains all reusable codes that are frequently used in the Experience Designer and Experience Manager.

The following code shows how the output is the value assigned to the variable a.

The following code truncates the HTML tags (except <hr> and <br> tags) that are obtained from the Say nodes, taxonomy, and so on.

cryptoJS

The cryptoJS module provides cryptographic functionality that includes a set of wrappers for OpenSSL's hash, HMAC, cipher, decipher, sign, and verify functions. Using cryptoJS, you can send the encrypted data to the server.
See npm: crypto-js and CryptoJS | CryptoJS.

Use global.get('cryptoJS') to access this module.

The output of the above code is:

zipcodeToTimezone

The zipcodeToTimezone module converts Zipcode data to the corresponding Timezone.
See npm: zipcode-to-timezone.

Use global.get('zipcode-to-timezone') to access this module.

The output of the above code is:

google-libphonenumber

The google-libphonenumber library can parse, format, store, and validate international phone numbers.
See npm: google-libphonenumber.

Usage:

Output:

Related Articles