Overview
The DocumentGenerator node's "Render Template" operation allows you to generate text output by rendering input data through a Handlebars template. This is useful for dynamically creating documents, emails, reports, or any text-based content based on your workflow data.
Common scenarios:
- Generating personalized email bodies from contact lists.
- Creating custom-formatted reports from tabular data.
- Producing templated messages or notifications using workflow variables.
Practical example:
If you have a list of users and want to send each a customized message, you can use this node to render the message body with user-specific details.
Properties
| Display Name | Type | Meaning |
|---|---|---|
| Render All Items with One Template | boolean | If enabled, all input items are rendered together using a single template (useful for batch processing, e.g., tables). Otherwise, each item is rendered individually with its own template context. |
| Use a Template String | boolean | Choose whether to provide the template directly as a string (enabled) or fetch it from a URL (disabled). |
| Template String | string | The Handlebars template to use for rendering, entered directly in the node. Only shown if "Use a Template String" is enabled. |
| Template URL | string | The URL from which to fetch the Handlebars template. Only shown if "Use a Template String" is disabled. |
| Define a Custom Output Key | boolean | If enabled, lets you specify a custom property name for the rendered output instead of the default "text". |
| Output Key | string | The property name where the rendered text will be stored in the output. Only shown if "Define a Custom Output Key" is enabled. |
Output
- The node outputs an array of items, each containing a
jsonobject. - By default, the rendered text is placed under the
textkey in thejsonobject. If a custom output key is defined, the rendered text appears under that key instead.
Output Structure Example
When rendering each item individually:
[
{
"json": {
"text": "Rendered output for item 1"
}
},
{
"json": {
"text": "Rendered output for item 2"
}
}
]
When rendering all items with one template:
[
{
"json": {
"text": "Rendered output for all items"
}
}
]
Note: Replace "text" with your custom output key if specified.
- No binary data is produced by this node.
Dependencies
- External Library: Uses @jaredwray/fumanchu for Handlebars template rendering.
- Template URL: If using a template URL, the node requires network access to fetch the template.
- No credentials or API keys are required unless your template URL is protected.
Troubleshooting
Common Issues:
Invalid Handlebars Syntax:
If your template contains errors, rendering will fail. Double-check your template against the Handlebars documentation.Missing Required Fields:
If required properties like "Template String" or "Template URL" are not provided, the node will throw an error.Network Errors (Template URL):
If the node cannot fetch the template from the provided URL (e.g., due to network issues or invalid URL), it will fail. Ensure the URL is correct and accessible.Output Key Conflicts:
If you define a custom output key that conflicts with existing fields in your data, it may overwrite them.
Error Messages:
- "Cannot read property 'compile' of undefined" — Indicates a problem with the Handlebars library or template loading.
- "Request failed with status code..." — Problem fetching the template from the URL; check connectivity and URL correctness.