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: https://github.com/HubSpot/jinjava 

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{{env.name}}The data coming from an env.
dict{{dict.name}}The data coming from an event.
var{{var.name}}The data coming from a connector or table.
config{{config.name}}The data coming from this connnector's  properties.
executionContext{{executionContent.name}}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

VariableDescription
{{env.name}}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
    properties:
      jsonObject: >
       [
         { "leadId": "1", "firstName": "{{config.hello}}", "lastName": "Thomas", "leadScore": 88 },
         { "leadId": "2", "firstName": "Anne", "lastName": "Jacobs", "leadScore": 32 }
       ]
      hello: world

Custom Jinja Functions

FunctionDescription
date_formatFormats the date and time.

Example usage: Format the current time in a file name in the SFTP connector.
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
https://designers.hubspot.com/docs/hubl/if-statements

For Loops
https://designers.hubspot.com/docs/hubl/for-loops

Filters
https://designers.hubspot.com/docs/hubl/hubl-supported-filters