@axway/api-builder-plugin-fn-dot v2.2.1
@axway/api-builder-plugin-fn-dot
About
This plugin 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.
⚠️ Warning: Installing this module may report a security vulnerability with doT. This is because doT templates can be used to execute malicious JavaScript.
Templates should never come from untrusted sources. If you trust all the templates that you use, then you can safely ignore the vulnerability and continue to use this plugin.
This plugin is no longer bundled with new API Builder projects. We suggest using @axway/api-builder-plugin-fn-javascript instead of the formatObject method, or @axway/api-builder-plugin-fn-mustache instead of formatString.
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
- Follow the Getting Started Guide
Install
After creating your API Builder service (api-builder init), you can install this plugin using npm:
npm install --no-optional @axway/api-builder-plugin-fn-dotThe "Compose" flow-node will then be available in the tools panel when creating or editing Flows.
Changes
2.2.0
- #6933: Replace peerDependency on @axway/api-builder-runtime with
engines.apibuilder.
2.1.4
- #7057: Updated documentation links.
2.1.3
- #6934: Internal refactoring around code style.
2.1.2
- #6315: Internal chore.
2.1.1
- #6116: Bump
axway-flow-sdkdependency.
2.1.0
- #6093: Removed the explicit maximum supported Node.js version limitation in package.json.
- #6093: Internal test suite clean up.
2.0.15
- #6026: Documents ranges of supported Node.js versions in package.json
2.0.14
- #6074: Internal CI chore.
2.0.13
- #5893: Update readme with security vulnerability warning and alternative plugins.
2.0.4 - 2.0.12
- #5891: Bump
axway-flow-sdkdependency.
2.0.3
- #5711: Internal cleanup of npm scripts.
2.0.2
- #5708: Internal changes to update mocha configuration.
2.0.1
- #5707: Internal cleanup to code coverage during build process.
2.0.0
- #5742: Update
axway-flow-sdkdependency to reduce security vulnerabilities ondotmodule. - #5742: Breaking Change: Minimum supported version of API Builder is now 4.5.0
1.0.14
- #5050: Updating license text.
1.0.8
- #4757: Changed SCM repository and associated internal cleanup.
License
This code is proprietary, closed source software licensed to you by Axway. All Rights Reserved. You may not modify Axway’s code without express written permission of Axway. You are licensed to use and distribute your services developed with the use of this software and dependencies, including distributing reasonable and appropriate portions of the Axway code and dependencies. Except as set forth above, this code MUST not be copied or otherwise redistributed without express written permission of Axway. This module is licensed as part of the Axway Platform and governed under the terms of the Axway license agreement (General Conditions) located here: https://support.axway.com/en/auth/general-conditions; EXCEPT THAT IF YOU RECEIVED A FREE SUBSCRIPTION, LICENSE, OR SUPPORT SUBSCRIPTION FOR THIS CODE, NOTWITHSTANDING THE LANGUAGE OF THE GENERAL CONDITIONS, AXWAY HEREBY DISCLAIMS ALL SUPPORT AND MAINTENANCE OBLIGATIONS, AS WELL AS ALL EXPRESS AND IMPLIED WARRANTIES, INCLUDING BUT NOT LIMITED TO IMPLIED INFRINGEMENT WARRANTIES, WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, AND YOU ACCEPT THE PRODUCT AS-IS AND WITH ALL FAULTS, SOLELY AT YOUR OWN RISK. Your right to use this software is strictly limited to the term (if any) of the license or subscription originally granted to you.
3 years ago
4 years ago
4 years ago
4 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago