StringTemplate

Overview¶
The StringTemplate Block allows you to generate a string by using a template and dynamically inserting values into it. This is useful when you want to build strings based on inputs with specific formatting. It uses the jinja2 templating engine to render the template.
Description¶
Metadata¶
- Category: Misc
 
Configuration Options¶
| Name | Data Type | Description | Default Value | 
|---|---|---|---|
| template | str | 
Inputs¶
| Name | Data Type | Description | 
|---|---|---|
| **inputs | Any | 
Outputs¶
| Name | Data Type | Description | 
|---|---|---|
| string | str | 
State Variables¶
No state variables available.
Example(s)¶
Example 1: Build a string with dynamic values¶
- Create a 
StringTemplateBlock. - Set the 
templateto"Hello, {{ name }}!". - Provide the input: 
{"name": "John"}. - The Block will output: 
"Hello, John!". 
Error Handling¶
- If the template contains invalid syntax, the Block will raise an error.
 
FAQ¶
What happens if a required input is missing?
The Block will raise a KeyError if the template expects a variable that is not provided in the inputs.