Recipes can be parameterized using Jinja expressions. Jinja expression replacement happens at run-time at different stages of recipes execution. Jinja is not designed for transformation.

Recipes use JinJava.  This library has many similarities to Python Jinja, but there are some differences. Looking at the examples on GitHub can help with general usage and specific implementation details. See: 

Depending on your use case, you can often use SQL transformation in SELECT statements with Jinja expressions in connector properties to shape your data.

Public Recipe Library Examples

Lingk Variable Collections

Variable CollectionExamplePurpose
env{{}}The data coming from an env.
dict{{}}The data coming from an event.
var{{}}The data coming from a connector or table.
config{{}}The data coming from this connnector's  properties.
executionContext{{}}The data coming from the execution context table.

The env Variable Collection

Scope: Statements and Connector Properties
Type: Static

The env Collection provides you with information about the environment that the recipe is running in. This can be helpful for pulling in environment specific values from lookups (file or API) during recipe execution. 

Available Variables

{{}}The name of the environment. 

The dict Variable Collection

Scope: Statements and Connector Properties
Type:  Dynamic

The dict collection contains the JSON structure passed in via event-triggered recipe execution. This collection is ideal for parameterizing a recipe to be used in different contexts based on external events.

The var Variable Collection

Scope: Connector Properties
Type:  Dynamic

The var collection contains a tabular dataset resulting from a ParameterizedBy property with REFRESH or from INSERT, UPDATE, or DELETE payloads. Use the Var collection like a "For" loop on a connector to parameterized properties with values from a previous statement. 

The executionContext Variable Collection

Scope: Statements and Connector Properties
Type:  Dynamic

The executionContext collection contains data inserted into the executionContext table during a statement. By default, executionContext is empty until you perform the following statement:

  - statement: INSERT someData INTO executionContext

After this statement, data is in the  executionContext dataset and accessible in connector properties after a REFRESH statement.

executionContext is commonly used for storing an authorization token used in an OAuth flow that impacts multiple connectors during the execution of a recipe.

The config Variable Collection

Scope:  Individual Connector Properties
Type:  Dynamic

The config collection contains a list of configuration properties on a connector.

Here is an example connector that utilizes the config collection of data.

    name: sourceLeadData
    type: json
      jsonObject: >
         { "leadId": "1", "firstName": "{{config.hello}}", "lastName": "Thomas", "leadScore": 88 },
         { "leadId": "2", "firstName": "Anne", "lastName": "Jacobs", "leadScore": 32 }
      hello: world

Custom Jinja Functions

date_formatFormats the date and time.

Example usage: Format the current time in a file name in the SFTP connector.

{{ func:date_format(func:current_datetime(), 'yyyy-MM-dd_HH-mm-ss') }}

For formatting examples, see:
current_datetimeReturns the current date time.

More about Jinja Expressions

Our expression language uses the same library as HubSpot's HUBL template language. These expressions are typically used along side the JSON Connector for building custom JSON. However, it's may be easier to build custom JSON using Spark SQL.

If Statements

For Loops