This package has been deprecated

    Author message:

    Support for API Builder 3.x will cease on 30th April 2020. Use the v3 to v4 upgrade guide (https://docs.axway.com/bundle/API_Builder_4x_allOS_en/page/api_builder_v3_to_v4_upgrade_guide.html) to migrate all your applications to API Builder 4.x.

    nodehandler-dot

    1.2.13 • Public • Published

    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.

    Param Type Required Description
    data object y The data to evaluate the template with. Use $ to access the entire context.
    template string y The 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.

    Param Type Required Description
    data object y The data to evaluate the template with. Use $ to access the entire context.
    template string y The 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.

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

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

    Request http://localhost:8080/api/example?firstname=Clark&lastname=Kent&gender=m
    data $
    template Hello {{? it.gender=="m"}}Mr {{?}}{{? it.gender=="f"}}Ms {{?}}{{= it.surname}}
    Output Hello Mr Kent
    Request http://localhost:8080/api/example?firstname=Lois&lastname=Lane&gender=f
    data $
    template Hello {{? it.gender=="m"}}Mr {{?}}{{? it.gender=="f"}}Ms {{?}}{{= it.surname}}
    Output Hello Ms Lane
    Array Iteration {{~ }}

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

    Request http://localhost:8080/api/example?names=Tom,Dick,Harry
    data $
    template {{~it.params.names :value:index}}{{=index}}={{=value}};{{~}}
    Output 0=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.

    Install

    npm i nodehandler-dot

    DownloadsWeekly Downloads

    7

    Version

    1.2.13

    License

    SEE LICENCE IN LICENSE

    Unpacked Size

    13.3 kB

    Total Files

    6

    Last publish

    Collaborators

    • ddimonov-axway
    • axway_darnaudov
    • nkeranova
    • axway-npm
    • cb1kenobi
    • jamie.peabody
    • awam
    • bladedancer
    • neon-axway
    • vchauhan
    • mdimitrova
    • pdzhorev
    • axway_alasdair
    • pltod2
    • npetrovski-axway
    • pbozhkovaxway
    • mbonchev-axway
    • axway-vertex
    • cdobrica