Action that transforms data using Nunjucks templates Provides powerful templating capabilities for data transformation

Example

// Simple object mapping
await runAction({
ActionName: 'Data Mapper',
Params: [{
Name: 'SourceData',
Value: { user: { firstName: 'John', lastName: 'Doe', age: 30 } }
}, {
Name: 'MappingTemplate',
Value: {
fullName: '{{ user.firstName }} {{ user.lastName }}',
displayName: '{{ user.firstName | upper }}',
ageGroup: '{% if user.age < 18 %}minor{% elif user.age < 65 %}adult{% else %}senior{% endif %}'
}
}]
});

// Array transformation
await runAction({
ActionName: 'Data Mapper',
Params: [{
Name: 'SourceData',
Value: [{ price: 10, qty: 2 }, { price: 20, qty: 1 }]
}, {
Name: 'MappingTemplate',
Value: {
total: '{{ price * qty }}',
formattedPrice: '${{ price | number(2) }}'
}
}, {
Name: 'IterateArrays',
Value: true
}]
});

// String template
await runAction({
ActionName: 'Data Mapper',
Params: [{
Name: 'SourceData',
Value: { name: 'John', items: ['apple', 'banana'] }
}, {
Name: 'MappingTemplate',
Value: 'Hello {{ name }}, you have {{ items | length }} items: {{ items | join(", ") }}'
}, {
Name: 'TemplateType',
Value: 'string'
}]
});

Hierarchy (view full)

Constructors

Properties

nunjucksEnv: Environment

Methods

  • Transform data using Nunjucks templates

    Parameters

    • params: RunActionParams<any>

      The action parameters containing:

      • SourceData: Input object or array to transform
      • MappingTemplate: Nunjucks template string or object with templates
      • TemplateType: "string" | "object" (default: "object")
      • IterateArrays: Boolean - if true, map each array item (default: false)
      • CustomFilters: Object with custom Nunjucks filters (optional)
      • StrictVariables: Boolean - throw error on undefined variables (default: false)

    Returns Promise<ActionResultSimple>

    Transformed data based on templates

  • Executes the action with the provided parameters.

    Parameters

    • params: RunActionParams<any>

      The action execution parameters including context

    Returns Promise<ActionResultSimple>

    Promise resolving to the action result