1.2.13 • Published 5 years ago

nodehandler-dot v1.2.13

Weekly downloads
150
License
SEE LICENCE IN LI...
Repository
-
Last release
5 years ago

nodehandler-dot

About

This module installs the doT Compose flow-node to be used within Axway API Builder's flow editor.

The Template flow-node allows the evaluation of doT templates using values from the flow.

Format string

The Format string method evaluates the doT template given with the data supplied. This allows complex values to be constructed from values that exist in the flow's context.

ParamTypeRequiredDescription
dataobjectyThe data to evaluate the template with. Use $ to access the entire context.
templatestringyThe doT template being evaluated.

Format object

The Format object method is similar to the Format string method. It evaluates the doT template given with the data supplied. However the resulting string value is then JSON parsed. This allows the creation of JavaScript values and objects from the evaluated template.

ParamTypeRequiredDescription
dataobjectyThe data to evaluate the template with. Use $ to access the entire context.
templatestringyThe doT template being evaluated.

doT Templates

doT is a JavaScript templating engine. As well as template evaluation, it supports features such as conditionals and iteration.

In the template, it is used to refer to the data.

Example

In the examples the Flow is going to be attached to an API that has three parameters, firstname, lastname and gender.

Basic interpolation {{= }}

The template can be used to quickly concatenate values.

Requesthttp://localhost:8080/api/example?firstname=Clark&lastname=Kent&gender=m
data$
template{{=it.params.firstname}} {{=it.params.lastname}}
OutputClark Kent
Conditionals {{? }}

The template evaluation supports conditional logic to tailor the output based on the input.

Requesthttp://localhost:8080/api/example?firstname=Clark&lastname=Kent&gender=m
data$
templateHello {{? it.gender=="m"}}Mr {{?}}{{? it.gender=="f"}}Ms {{?}}{{= it.surname}}
OutputHello Mr Kent
Requesthttp://localhost:8080/api/example?firstname=Lois&lastname=Lane&gender=f
data$
templateHello {{? it.gender=="m"}}Mr {{?}}{{? it.gender=="f"}}Ms {{?}}{{= it.surname}}
OutputHello Ms Lane
Array Iteration {{~ }}

The template engine can also iterate over arrays, creating content for each element in the array.

Requesthttp://localhost:8080/api/example?names=Tom,Dick,Harry
data$
template{{~it.params.names :value:index}}{{=index}}={{=value}};{{~}}
Output0=Tom;1=Dick;2=Harry;

Getting started

  1. Go to platform.axway.com and create an account
  2. Install API Builder
  3. Follow the Getting Started Guide

Install

After creating your API Builder project (appc new -t arrow), you can install this flow-node handler using npm:

npm install --save nodehandler-dot

The "Compose" flow-node will then be available in the tools panel when creating or editing Flows.

1.2.13

5 years ago

1.2.12

5 years ago

1.2.11

5 years ago

1.2.10

5 years ago

1.2.9

5 years ago

1.2.7

5 years ago

1.2.5

5 years ago

1.2.4

6 years ago

1.1.1

6 years ago

2.0.0-10

6 years ago

2.0.0-9

6 years ago

2.0.0-8

6 years ago

2.0.0-7

6 years ago

2.0.0-6

6 years ago

2.0.0-5

6 years ago

2.0.0-4

6 years ago

2.0.0-3

6 years ago

2.0.0-2

6 years ago

2.0.0-1

6 years ago

1.1.1-8

6 years ago

1.1.1-7

6 years ago

1.1.1-6

6 years ago

1.1.1-5

6 years ago

1.1.1-4

6 years ago

1.1.1-3

6 years ago

1.1.1-2

6 years ago

1.1.1-1

6 years ago

1.1.1-0

6 years ago

1.1.0

6 years ago

1.1.0-107

6 years ago

1.1.0-106

6 years ago

1.1.0-105

6 years ago

1.1.0-104

6 years ago

1.1.0-103

6 years ago

1.1.0-102

6 years ago

1.1.0-101

6 years ago

1.0.0

6 years ago